Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Attach and View Files for an Invoice? #115

Open
shajeerEmiratesZone opened this issue May 18, 2024 · 3 comments
Open

How to Attach and View Files for an Invoice? #115

shajeerEmiratesZone opened this issue May 18, 2024 · 3 comments

Comments

@shajeerEmiratesZone
Copy link

Hi, I'm trying to attach Files to Invoice and retrieve them using Zohobooks API. But I don't see any option for this. Can anyone guide me how to do this using the package or if the implementation exist in the package.
The URL for file attachment (POST) and retrieval (GET) is : https://zohoapis.com/books/v3/invoices/{invoiceID}/attachment?organization_id={org_id};

@shajeerEmiratesZone shajeerEmiratesZone changed the title How to Attach and View Files for an Invoice How to Attach and View Files for an Invoice ? May 18, 2024
@shajeerEmiratesZone shajeerEmiratesZone changed the title How to Attach and View Files for an Invoice ? How to Attach and View Files for an Invoice? May 18, 2024
@Skullbock
Copy link
Contributor

Hi, i don't think there is a dedicated method yet in the API. Check the doAction method on the module $zoho->invoices->doAction($id, 'attachment', $data) if can cover the use case.

Otherwise, PR are welcome!

@shajeerEmiratesZone
Copy link
Author

Hello,

Thank you for your reply. How can I send the attachment file here? Using cURL, I can upload the attachment as shown in the code below:

$tmpfile = $file['tmp_name'];
$filename = basename($file['name']);
$cFile = curl_file_create($tmpfile, $file['type'], $filename);
$post = [
    'can_send_in_mail' => 'false',
    'attachment' => $cFile
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $request_url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Zoho-oauthtoken ' . $accessToken,
]);

$response = curl_exec($ch);
curl_close($ch);

$response_data = json_decode($response);
return $response_data;

@Skullbock
Copy link
Contributor

Hi! if you can PR the feature, the best place to do so is to add a new method, like uploadAttachment to the invoices module. You can find a similar method here:

https://github.com/Weble/ZohoBooksApi/blob/develop/src/Modules/Invoices.php#L140

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants