Skip to content

Commit d89ab38

Browse files
committed
add Receipts.send_by_email and Receipts.download_pdf
1 parent d56f1f1 commit d89ab38

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/Resources/Receipts.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,40 @@ public function cancel( $id ) {
115115
}
116116
}
117117

118+
/**
119+
* Sends the receipt to the customer's email
120+
*
121+
* @param id : Unique ID for Receipt
122+
*
123+
* @return JSON object for requested Receipt
124+
*
125+
* @throws Facturapi_Exception
126+
**/
127+
public function send_by_email( $id, $email = null ) {
128+
try {
129+
return json_decode( $this->execute_JSON_post_request(
130+
$this->get_request_url($id) . "/email",
131+
$email == null ? array() : array("email" => $email)
132+
));
133+
} catch ( Facturapi_Exception $e ) {
134+
throw new Facturapi_Exception( 'Unable to send Receipt: ' . $e );
135+
}
136+
}
137+
138+
/**
139+
* Downloads the specified receipt in a PDF file
140+
*
141+
* @param id : Unique ID for Receipt
142+
*
143+
* @return PDF file in a stream
144+
*
145+
* @throws Facturapi_Exception
146+
**/
147+
public function download_pdf( $id ) {
148+
try {
149+
return $this->execute_get_request( $this->get_request_url( $id ) . "/pdf" );
150+
} catch ( Facturapi_Exception $e ) {
151+
throw new Facturapi_Exception( 'Unable to download PDF file: ' . $e );
152+
}
153+
}
118154
}

0 commit comments

Comments
 (0)