Git Product home page Git Product logo

zoho_invoice's Introduction

Zoho Invoice

Build Status Coverage Status

Need to interact with the Zoho Invoice API? The zoho_invoice gem has your back.

Until the gem reaches 1.0, the interface for interacting with the gem could change. On top of that the gem does not support the entire API just yet. Just the minimum number of domain objects to actually create customers and invoices. This will change over time.

Status

This README covers Zoho's old Invoice API v2. Work has started on integrating version three of the API and that can be found on the version_three branch.

Installation

Add this line to your application's Gemfile:

gem 'zoho_invoice'

And then execute:

$ bundle

Or install it yourself as:

$ gem install zoho_invoice

Configuration

The Zoho Invoice API service requires that you generate an auth token ahead of time using the API, just once. Fortunately, the gem can handle that in console for you, all you need is your username and password. Then you can save the authtoken in your project based on however you do your configuration.

homebase $ irb
> require 'zoho_invoice'
 => true
> result = ZohoInvoice::AuthToken.generate_authtoken('[email protected]', 'thisismysweetpassword')
 => #<struct ZohoInvoice::AuthToken::AuthTokenResult authtoken="blahblahblahnumbersnstuff", cause=nil>
> result.success?
 => true
> result.authtoken
 => "blahblahblahnumbersnstuff"

Client Setup

One of the great things about zoho_invoice is the ability for clients to inherit from a global config and override it if need be.

homebase $ irb
> require 'zoho_invoice'
 => true
> ZohoInvoice.authtoken = 'first_authtoken'
 => "first_authtoken"
> ZohoInvoice.apikey = 'first_apikey'
 => "first_apikey"
> client = ZohoInvoice::Client.new
 => #<ZohoInvoice::Client:0x007f9e6cf274b8 @authtoken="first_authtoken", @scope="invoiceapi", @apikey="first_apikey", @client_options={:url=>"https://invoice.zoho.com"}>
> another_client = ZohoInvoice::Client.new(:authtoken => "override_authtoken")
 => #<ZohoInvoice::Client:0x007f9e6cf395a0 @authtoken="override_authtoken", @scope="invoiceapi", @apikey="first_apikey", @client_options={:url=>"https://invoice.zoho.com"}>

Usage

require 'zoho_invoice'

client = ZohoInvoice::Client.new(:authtoken => 'my authtoken', :apikey => 'my apikey')

invoice = ZohoInvoice::Invoice.new(client, :customer_id => 'asdf')
invoice.save

If you're so inclined, you can scope the resources through the client.

require 'zoho_invoice'

client = ZohoInvoice::Client.new(:authtoken => 'my authtoken', :apikey => 'my apikey')
invoice = client.invoices.new(:customer_id => 'asdf')
invoice.save

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

zoho_invoice's People

Contributors

mattbradley avatar neovintage avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

zoho_invoice's Issues

Validation errors from the API are not surfacing

When you try to save an invoice and there's some kind of validation error from the Zoho service, there's no feedback on the object that the save didn't happen. We should probably create some kind of error method on the object that's trying to be saved.

How to retrieve values of Custom Fields from the Invoice objects?

Dear Author of the Zoho_Invoice Gem:

I am a very happy user of this gem -- thanks so much for making it available!

I hope you can help me with this question. Our Invoice records utilize Custom Fields, and I was trying to retrieve the values of these Custom Fields via the zoho_invoice gem utilities; however, I have not been able to figure out how to do that. Is there a way to do so? If yes, could you please share it with me? Or is this the limitation of the underlying Zoho Invoice XML API itself? I have sent an inquiry to their support, but have not heard back yet.

Thank you for your help.

Sincerely,
--Alex Sherstinsky

Error on creation of invoice

I'm following the basic example to create and invoice and it gives me a error 500.
I added some logs but don't help that much.

client = ZohoInvoice::Client.new(:authtoken => ENV['ZOHOINVAUTH'], :apikey => ENV['ZOHOAPIKEY'])

invoice = client.invoices.new(:customer_id => 'asdf')

invoice.save

server responded with status 500
{:status=>500, :headers=>{"server"=>"ZGS", "date"=>"Wed, 11 Jun 2014 12:29:09 GMT", "content-type"=>"text/xml;charset=UTF-8", "transfer-encoding"=>"chunked", "connection"=>"close", "set-cookie"=>"d9c0a2d222=25bf71d25c6db2ab3322e47803959500; Path=/, JSESSIONID=07D975541AECAF142CDBED620B0296B9; Path=/, zbcscook=140c7dc1-63c1-4440-aa8a-a111e9f0c1d4; Path=/; Secure", "x-frame-options"=>"TRUSTED", "x-content-type-options"=>"nosniff", "x-xss-protection"=>"1", "pragma"=>"no-cache", "cache-control"=>"no-cache", "expires"=>"Thu, 01 Jan 1970 00:00:00 GMT", "api_version"=>"Jun_10_2014_2_9751"}, :body=>{"Response"=>{"Code"=>"1000", "Message"=>"Internal Error", "status"=>"0"}}}
ZohoInvoice::Error::ClientError: ZohoInvoice::Error::ClientError

I imagine it requires more data to create the invoice. I've tried with more stuff in the invoice to create but got the same error.

Any hints?
Which version of the Zoho invoice API it supports btw?

Thanks.

Fails to create invoice. No invoice_items included?

Hi,

First of all thanks for this gem, I've been able to quickly get customers out of Zoho, now I'm trying to send invoices but I'm running into some trouble.

This is what ZohoInvoice self looks like, you can see it includes invoice_items:

invoice

However when I check this: XMLString => self.to_xml

I don't see any InvoiceItems

"<?xml version="1.0"?>
<Invoice>
  <InvoiceNumber>18</InvoiceNumber>
  <CustomerID>562674000000039020</CustomerID>
  <InvoiceDate>2014-10-17</InvoiceDate>
  <InvoiceItems><InvoiceItem/>
<InvoiceItem/>
<InvoiceItem/>
<InvoiceItem/>
<InvoiceItem/>
<InvoiceItem/>
</InvoiceItems>
</Invoice>
"

This is the result.body I'm getting:

'Code': 4091
'Message': Select an item or give a description to create the invoice.
'Status': 0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.