├── spec
├── fixtures
│ ├── ok.xml
│ ├── clients.update.xml
│ ├── po.email_document.xml
│ ├── users.change-account.xml
│ ├── simplified_invoices.update.xml
│ ├── clients.create.xml
│ ├── taxes.create.xml
│ ├── taxes.update.xml
│ ├── invoices.update_state.xml
│ ├── po.update_state.xml
│ ├── credit_notes.update_state.xml
│ ├── credit_notes.email_document.xml
│ ├── simplified_invoices.update_state.xml
│ ├── charts.top-clients.xml
│ ├── charts.top-debtors.xml
│ ├── item.xml
│ ├── simplified_invoices.email_document.xml
│ ├── users.login.xml
│ ├── clients.invoices.xml
│ ├── sequences.create.xml
│ ├── users.accounts.xml
│ ├── sequences.get.xml
│ ├── sequences.update.xml
│ ├── taxes.list.xml
│ ├── clients.list.xml
│ ├── sequences.list.xml
│ ├── charts.invoicing.xml
│ ├── charts.quarterly-results.xml
│ ├── clients.get.xml
│ ├── invoices.create.xml
│ ├── schedules.list.xml
│ ├── po.get.xml
│ ├── po.create.xml
│ ├── schedules.create.xml
│ ├── po.list.xml
│ ├── invoices.get.xml
│ ├── charts.treasury.xml
│ ├── credit_notes.create.xml
│ ├── schedules.get.xml
│ ├── simplified_invoices.create.xml
│ ├── simplified_invoices.get.xml
│ ├── credit_notes.list.xml
│ └── simplified_invoices.list.xml
├── invoicexpress
│ ├── models
│ │ └── item_spec.rb
│ ├── client_spec.rb
│ └── client
│ │ ├── users_spec.rb
│ │ ├── taxes_spec.rb
│ │ ├── sequences_spec.rb
│ │ ├── charts_spec.rb
│ │ ├── clients_spec.rb
│ │ ├── invoices_spec.rb
│ │ ├── credit_notes_spec.rb
│ │ ├── schedules_spec.rb
│ │ ├── purchase_orders_spec.rb
│ │ └── simplified_invoices_spec.rb
├── invoicexpress_spec.rb
└── helper.rb
├── .travis.yml
├── doc
└── yard
│ ├── css
│ └── common.css
│ ├── frames.html
│ ├── file_list.html
│ ├── top-level-namespace.html
│ ├── Invoicexpress
│ ├── Connection.html
│ └── Models
│ │ ├── Errors.html
│ │ ├── Value.html
│ │ ├── InvoiceResult.html
│ │ ├── Tax.html
│ │ ├── Item.html
│ │ ├── Chart.html
│ │ ├── Graph.html
│ │ ├── Items.html
│ │ ├── Client.html
│ │ ├── Graphs.html
│ │ ├── Series.html
│ │ ├── Account.html
│ │ ├── Message.html
│ │ ├── Invoices.html
│ │ ├── Sequence.html
│ │ ├── Supplier.html
│ │ ├── Schedules.html
│ │ ├── TopClient.html
│ │ ├── TopDebtor.html
│ │ ├── Credentials.html
│ │ └── CreditNotes.html
│ └── Faraday.html
├── lib
├── invoicexpress
│ ├── version.rb
│ ├── authentication.rb
│ ├── models
│ │ ├── top_debtor.rb
│ │ ├── top_client.rb
│ │ ├── supplier.rb
│ │ ├── sequence.rb
│ │ ├── client.rb
│ │ ├── user.rb
│ │ ├── chart.rb
│ │ ├── quarterly_result.rb
│ │ ├── filter.rb
│ │ ├── purchase_order.rb
│ │ └── schedule.rb
│ ├── models.rb
│ ├── connection.rb
│ ├── configuration.rb
│ ├── error.rb
│ ├── request.rb
│ ├── client.rb
│ └── client
│ │ ├── users.rb
│ │ ├── charts.rb
│ │ ├── sequences.rb
│ │ ├── taxes.rb
│ │ └── items.rb
├── faraday
│ └── response
│ │ ├── parse_xml.rb
│ │ └── raise_invoicexpress_errors.rb
└── invoicexpress.rb
├── .gitignore
├── Gemfile
├── Rakefile
├── CHANGELOG.md
├── invoicexpress.gemspec
└── README.md
/spec/fixtures/ok.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/spec/fixtures/clients.update.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/spec/fixtures/po.email_document.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/spec/fixtures/users.change-account.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/spec/fixtures/simplified_invoices.update.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: ruby
2 | rvm:
3 | - 2.1.3
4 | - 1.9.3
5 |
--------------------------------------------------------------------------------
/doc/yard/css/common.css:
--------------------------------------------------------------------------------
1 | /* Override this file with custom rules */
--------------------------------------------------------------------------------
/lib/invoicexpress/version.rb:
--------------------------------------------------------------------------------
1 | module Invoicexpress
2 | Invoicexpress::VERSION = "0.1.7"
3 |
4 | VERSION = "0.0.0" unless defined?(Invoicexpress::VERSION)
5 | end
6 |
--------------------------------------------------------------------------------
/spec/fixtures/clients.create.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 1
4 | Ruben Fonseca
5 | fonseka@gmail.com
6 |
7 |
--------------------------------------------------------------------------------
/spec/fixtures/taxes.create.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | IVA19
4 | 19.0
5 | PT
6 | 1
7 |
8 |
--------------------------------------------------------------------------------
/spec/fixtures/taxes.update.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | IVA23
4 | 23.0
5 | PT
6 | 1
7 |
8 |
--------------------------------------------------------------------------------
/spec/fixtures/invoices.update_state.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 1503698
4 | Invoice
5 | 2/2013
6 | final
7 |
8 |
--------------------------------------------------------------------------------
/spec/fixtures/po.update_state.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 1430338
4 | PurchaseOrder
5 | 1/2013
6 | final
7 |
--------------------------------------------------------------------------------
/spec/fixtures/credit_notes.update_state.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 1423940
4 | CreditNote
5 | 3/2013
6 | final
7 |
8 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | .bundle
4 | .config
5 | coverage
6 | InstalledFiles
7 | lib/bundler/man
8 | pkg
9 | rdoc
10 | spec/reports
11 | test/tmp
12 | test/version_tmp
13 | tmp
14 | *.DS_Store
15 | Gemfile.lock
16 | .yardoc
17 | _yardoc
18 | .rvmrc
19 |
--------------------------------------------------------------------------------
/spec/fixtures/credit_notes.email_document.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Pedro Sousa
5 | psousa@thinkorange.pt
6 |
7 | teste 123
8 | test
9 |
--------------------------------------------------------------------------------
/spec/fixtures/simplified_invoices.update_state.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 1425061
4 | SimplifiedInvoice
5 | 1/2013
6 | settled
7 |
8 |
--------------------------------------------------------------------------------
/spec/fixtures/charts.top-clients.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | €
4 |
5 | 393116
6 | Ruben Fonseca
7 | 60.0
8 |
9 |
10 |
--------------------------------------------------------------------------------
/spec/fixtures/charts.top-debtors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | €
4 |
5 | 393116
6 | Ruben Fonseca
7 | 60.0
8 |
9 |
10 |
--------------------------------------------------------------------------------
/spec/fixtures/item.xml:
--------------------------------------------------------------------------------
1 |
2 | -
3 | Test
4 |
5 | 0.0
6 | hour
7 |
8 | IVA23
9 | 23.0
10 |
11 |
--------------------------------------------------------------------------------
/spec/fixtures/simplified_invoices.email_document.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Pedro Sousa
5 | psousa@thinkorange.pt
6 |
7 | Hello world
8 | Here is the invoice.
9 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source "https://rubygems.org"
2 |
3 | gem 'rake'
4 | gem 'yard'
5 | # gem 'byebug'
6 |
7 | group :development do
8 | gem 'kramdown'
9 | gem 'pry'
10 | end
11 |
12 | group :test do
13 | gem 'rspec', '>= 2.11'
14 | gem 'webmock'
15 | gem 'simplecov', :require => false
16 | end
17 |
18 | gemspec
19 |
--------------------------------------------------------------------------------
/lib/invoicexpress/authentication.rb:
--------------------------------------------------------------------------------
1 | module Invoicexpress
2 | module Authentication
3 | def authentication
4 | if api_key
5 | { :api_key => api_key }
6 | else
7 | {}
8 | end
9 | end
10 |
11 | def authenticated?
12 | !authentication.empty?
13 | end
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/lib/invoicexpress/models/top_debtor.rb:
--------------------------------------------------------------------------------
1 | require 'invoicexpress/models/client'
2 |
3 | module Invoicexpress
4 | module Models
5 |
6 | class TopDebtor < BaseModel
7 | include HappyMapper
8 |
9 | tag 'top-debtors'
10 | element :currency, String
11 | has_many :clients, Client
12 | end
13 | end
14 | end
--------------------------------------------------------------------------------
/lib/invoicexpress/models/top_client.rb:
--------------------------------------------------------------------------------
1 | require 'invoicexpress/models/client'
2 |
3 | module Invoicexpress
4 | module Models
5 |
6 | class TopClient < BaseModel
7 | include HappyMapper
8 |
9 | tag 'top-clients'
10 | element :currency, String
11 |
12 | has_many :clients, Client
13 | end
14 | end
15 | end
--------------------------------------------------------------------------------
/spec/fixtures/users.login.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 13233
5 | thinkorangeteste
6 | https://thinkorangeteste.invoicexpress.net
7 | xptoxpto
8 | active
9 | false
10 |
11 |
--------------------------------------------------------------------------------
/spec/fixtures/clients.invoices.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 1
5 | 0
6 | 0
7 | 1
8 | 0
9 | 50
10 |
11 |
12 |
--------------------------------------------------------------------------------
/spec/fixtures/sequences.create.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 266500
4 | 2099
5 | 100
6 | 200
7 | 300
8 | 0
9 |
--------------------------------------------------------------------------------
/spec/fixtures/users.accounts.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 13233
5 | thinkorangeteste
6 | https://thinkorangeteste.invoicexpress.net
7 | xptoxpto
8 | Portugal
9 | active
10 | false
11 |
12 |
--------------------------------------------------------------------------------
/spec/fixtures/sequences.get.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 230568
4 | 2013
5 | 1
6 | 3
7 | 1
8 | 1
9 |
10 |
--------------------------------------------------------------------------------
/spec/fixtures/sequences.update.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 266500
4 | 2098
5 | 1
6 | 3
7 | 1
8 | 0
9 |
10 |
--------------------------------------------------------------------------------
/spec/invoicexpress/models/item_spec.rb:
--------------------------------------------------------------------------------
1 | require 'helper'
2 |
3 | describe Invoicexpress::Models::Item do
4 |
5 | describe '#tax' do
6 | let(:item) do
7 | Invoicexpress::Models::Item.parse(File.read(fixture('/item.xml')))
8 | end
9 |
10 | it 'returns an Invoicexpress::Models::Tax instance' do
11 | expect(item.tax).to be_a Invoicexpress::Models::Tax
12 | end
13 | end
14 |
15 | end
--------------------------------------------------------------------------------
/spec/fixtures/taxes.list.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 1
5 | IVA20
6 | 20
7 | PT
8 | 1
9 |
10 |
11 |
12 | 2
13 | IVA21
14 | 21
15 | PT
16 | 0
17 |
18 |
19 |
--------------------------------------------------------------------------------
/lib/invoicexpress/models/supplier.rb:
--------------------------------------------------------------------------------
1 | module Invoicexpress
2 | module Models
3 |
4 | class Supplier < BaseModel
5 | include HappyMapper
6 | tag 'supplier'
7 | element :id, String
8 | element :name, String
9 | element :code, String
10 | element :email, String
11 | element :address, String
12 | element :postal_code, String
13 | element :fiscal_id, String
14 | end
15 |
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/spec/fixtures/clients.list.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 393116
5 | Ruben Fonseca
6 | fonseka@gmail.com
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Rakefile:
--------------------------------------------------------------------------------
1 | require 'bundler'
2 | Bundler::GemHelper.install_tasks
3 |
4 | require 'rspec/core/rake_task'
5 | RSpec::Core::RakeTask.new(:spec)
6 |
7 | task :test => :spec
8 | task :default => :spec
9 |
10 | namespace :doc do
11 | require 'yard'
12 | YARD::Rake::YardocTask.new do |task|
13 | task.files = ['README.md', 'lib/**/*.rb']
14 | task.options = [
15 | '--output-dir', 'doc/yard',
16 | '--markup', 'markdown'
17 | ]
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/spec/invoicexpress_spec.rb:
--------------------------------------------------------------------------------
1 | require 'helper'
2 |
3 | describe Invoicexpress do
4 | after do
5 | Invoicexpress.reset
6 | end
7 |
8 | describe ".new" do
9 | it "is a Invoicexpress::Client" do
10 | Invoicexpress.new.should be_a Invoicexpress::Client
11 | end
12 | end
13 |
14 | describe ".responds_to?" do
15 | it "is true if method exists" do
16 | Invoicexpress.respond_to?(:new, true).should == true
17 | end
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/spec/fixtures/sequences.list.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 230568
5 | 2013
6 | 1
7 | 3
8 | 1
9 | 1
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/lib/invoicexpress/models/sequence.rb:
--------------------------------------------------------------------------------
1 | module Invoicexpress
2 | module Models
3 |
4 | class Sequence < BaseModel
5 | include HappyMapper
6 |
7 | tag 'sequence'
8 | element :id, String
9 | element :serie, String
10 | element :current_invoice_number, Integer
11 | element :current_credit_note_number, Integer
12 | element :current_debit_note_number, Integer
13 | element :default_sequence, Boolean
14 | end
15 |
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/lib/faraday/response/parse_xml.rb:
--------------------------------------------------------------------------------
1 | require 'faraday'
2 | #require 'pry'
3 |
4 | # @api private
5 | module Faraday
6 | class Response::ParseXML < Response::Middleware
7 |
8 | def initialize(app, klass)
9 | @klass = klass
10 |
11 | super(app)
12 | end
13 |
14 | def on_complete(env)
15 | if env[:body] and !env[:body].strip.empty?
16 | env[:body] = @klass.parse env[:body]
17 | else
18 | env[:body] = nil
19 | end
20 | end
21 |
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/lib/faraday/response/raise_invoicexpress_errors.rb:
--------------------------------------------------------------------------------
1 | require 'faraday'
2 |
3 | # @api private
4 | module Faraday
5 | class Response::RaiseInvoicexpressErrors < Response::Middleware
6 | ERROR_MAP = {
7 | 401 => Invoicexpress::Unauthorized,
8 | 422 => Invoicexpress::UnprocessableEntity,
9 | 500 => Invoicexpress::InternalServerError,
10 | }
11 |
12 | def on_complete(env)
13 | key = env[:status].to_i
14 |
15 | if ERROR_MAP.has_key? key
16 | raise ERROR_MAP[key].new(env)
17 | end
18 | end
19 | end
20 | end
21 |
--------------------------------------------------------------------------------
/spec/fixtures/charts.invoicing.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Sep
5 | Oct
6 | Nov
7 | Dec
8 | Jan
9 | Feb
10 |
11 |
12 |
13 | 0
14 | 0
15 | 0
16 | 0
17 | 0
18 | 60
19 |
20 |
21 |
--------------------------------------------------------------------------------
/spec/fixtures/charts.quarterly-results.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 2010
4 | €
5 |
6 | 60.0
7 | 0.0
8 |
9 |
10 |
11 | 0
12 | 0
13 |
14 |
15 |
16 | 0
17 | 0
18 |
19 |
20 |
21 | 0
22 | 0
23 |
24 |
25 |
--------------------------------------------------------------------------------
/spec/fixtures/clients.get.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 345
4 | Bruce Norris
5 | 1337
6 | foo@bar.com
7 | Badgad
8 | 123-456
9 | 1122331122
10 | www.brucenorris.com
11 | 4433551242
12 | 4433551243
13 |
14 | Rui Alves
15 | xpto@xpto.pt
16 | 4433551242
17 |
18 | Computer Processed
19 | 1
20 |
21 |
22 |
--------------------------------------------------------------------------------
/lib/invoicexpress/models/client.rb:
--------------------------------------------------------------------------------
1 | module Invoicexpress
2 | module Models
3 |
4 | class Client < BaseModel
5 | include HappyMapper
6 |
7 | element :id, Integer
8 | element :name, String
9 | element :code, Integer
10 | element :email, String
11 | element :address, String
12 | element :postal_code, String
13 | element :fiscal_id, String
14 | element :website, String
15 | element :phone, String
16 | element :fax, String
17 | element :observations, String
18 | element :send_options, Integer
19 | element :balance, Float
20 | element :country, String
21 | element :language, String
22 | end
23 |
24 | end
25 | end
26 |
--------------------------------------------------------------------------------
/lib/invoicexpress/models/user.rb:
--------------------------------------------------------------------------------
1 | module Invoicexpress
2 | module Models
3 |
4 | class Credentials < BaseModel
5 | include HappyMapper
6 |
7 | tag 'credentials'
8 | element :login, String
9 | element :password, String
10 | end
11 |
12 | class Account < BaseModel
13 | include HappyMapper
14 |
15 | tag 'account'
16 | element :id, String
17 | element :name, String
18 | element :url, String
19 | element :api_key, String
20 | element :state, String
21 | end
22 |
23 | class ChangeAccountTo < BaseModel
24 | include HappyMapper
25 |
26 | tag 'change_account_to'
27 | element :id, String
28 | end
29 |
30 | end
31 | end
32 |
--------------------------------------------------------------------------------
/spec/invoicexpress/client_spec.rb:
--------------------------------------------------------------------------------
1 | require 'helper'
2 |
3 | describe Invoicexpress::Client do
4 | before do
5 | Invoicexpress.reset
6 | end
7 |
8 | describe "api_endpoint" do
9 | after(:each) do
10 | Invoicexpress.reset
11 | end
12 |
13 | it "defaults to https://%s.app.invoicexpress.com/" do
14 | client = Invoicexpress::Client.new
15 | client.api_endpoint.should == "https://%s.app.invoicexpress.com/"
16 | end
17 |
18 | it "is set" do
19 | Invoicexpress.api_endpoint = "https://thinkorangeteste.app.invoicexpress.com/"
20 | client = Invoicexpress::Client.new
21 | client.api_endpoint.should == "https://thinkorangeteste.app.invoicexpress.com/"
22 | end
23 | end
24 | end
25 |
--------------------------------------------------------------------------------
/lib/invoicexpress.rb:
--------------------------------------------------------------------------------
1 | require 'invoicexpress/configuration'
2 | require 'invoicexpress/error'
3 | require 'invoicexpress/client'
4 |
5 | module Invoicexpress
6 | extend Configuration
7 |
8 | class << self
9 | # Alias for Invoicexpress::Client.new
10 | #
11 | # @return [Invoicexpress::Client]
12 | def new(options={})
13 | Invoicexpress::Client.new(options)
14 | end
15 |
16 | # Delegate to Octokit::Client.new
17 | def method_missing(method, *args, &block)
18 | return super unless new.respond_to?(method)
19 | new.send(method, *args, &block)
20 | end
21 |
22 | def respond_to?(method, include_private=false)
23 | new.respond_to?(method, include_private) || super(method, include_private)
24 | end
25 | end
26 | end
27 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Version 0.1.7
2 | Fix issue #7 - Wrong return type of Modes::Item#tax
3 | Added Travis
4 |
5 | # Version 0.1.6.1
6 | Renamed the invoice_email method to email_invoice for sending email. Extracted examples to own file.
7 |
8 | # Version 0.1.6
9 | Fixed url for send email. New url: http://invoicexpress.com/api/invoices/email-invoice
10 |
11 | # Version 0.1.5
12 | Added rate to invoice. Experimental.
13 |
14 | # Version 0.1.4.1
15 | Added language field to client. API endpoint now defaults to https://%s.app.invoicexpress.com/
16 |
17 | # Version 0.1.3
18 | Removed "rquire 'pry'". Fixed it for production.
19 |
20 | # Version 0.1.2
21 | Corrected information in gem.
22 |
23 | # Version 0.1.1
24 | Fixed bug with latest version of Faraday (>0.9.0) which prevented creating a new client.
25 |
26 | # Version 0.1.0
27 | Release!
28 |
--------------------------------------------------------------------------------
/lib/invoicexpress/models.rb:
--------------------------------------------------------------------------------
1 | require 'happymapper'
2 |
3 | module Invoicexpress
4 | module Models
5 | DATE_FORMAT = Proc.new { |value| value.strftime("%d/%m/%Y") unless value.nil? }
6 |
7 | class BaseModel
8 | def initialize(attributes = {})
9 | super()
10 |
11 | attributes.each { |k,v| self.send("#{k}=", v) }
12 | end
13 | end
14 | end
15 | end
16 |
17 | require 'invoicexpress/models/client'
18 | require 'invoicexpress/models/invoice'
19 | require 'invoicexpress/models/filter'
20 | require 'invoicexpress/models/sequence'
21 | require 'invoicexpress/models/user'
22 | require 'invoicexpress/models/chart'
23 | require 'invoicexpress/models/top_client'
24 | require 'invoicexpress/models/top_debtor'
25 | require 'invoicexpress/models/quarterly_result'
26 | require 'invoicexpress/models/schedule'
27 | require 'invoicexpress/models/purchase_order'
28 |
29 |
30 |
--------------------------------------------------------------------------------
/lib/invoicexpress/models/chart.rb:
--------------------------------------------------------------------------------
1 | module Invoicexpress
2 | module Models
3 | class Value
4 | include HappyMapper
5 | tag "value"
6 | content "value"
7 | attribute :xid, Integer
8 | end
9 |
10 | class Series < BaseModel
11 | include HappyMapper
12 |
13 | tag 'series'
14 | has_many :values, Value
15 | end
16 |
17 | class Graph < BaseModel
18 | include HappyMapper
19 |
20 | tag 'graph'
21 | attribute :gid, String
22 | attribute :title, String
23 | has_many :values, Value
24 | end
25 |
26 | class Graphs < BaseModel
27 | include HappyMapper
28 |
29 | tag 'graphs'
30 | has_many :graphs, Graph
31 | end
32 |
33 | class Chart < BaseModel
34 | include HappyMapper
35 |
36 | tag 'chart'
37 | has_one :series, Series
38 | has_many :graphs, Graph
39 | end
40 | end
41 | end
--------------------------------------------------------------------------------
/doc/yard/frames.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 | Documentation by YARD 0.8.5
8 |
9 |
22 |
28 |
29 |
--------------------------------------------------------------------------------
/invoicexpress.gemspec:
--------------------------------------------------------------------------------
1 | lib = File.expand_path("../lib", __FILE__)
2 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3 | require 'invoicexpress/version'
4 |
5 | Gem::Specification.new do |spec|
6 | spec.add_development_dependency 'bundler', '~> 1.0'
7 |
8 | spec.add_dependency 'faraday', '~> 0.8'
9 | spec.add_dependency 'faraday_middleware', '~> 0.9'
10 | spec.add_dependency 'happymapper', '~> 0.4'
11 |
12 | spec.authors = ["Think Orange"]
13 | spec.description = %q{Simple wrapper for invoicexpress.com API}
14 | spec.email = ['info@thinkorange.pt']
15 | spec.files = %w(CHANGELOG.md README.md Rakefile invoicexpress.gemspec)
16 | spec.files += Dir.glob("lib/**/*.rb")
17 | spec.files += Dir.glob("spec/**/*")
18 | spec.homepage = "http://invoicexpress.com"
19 | spec.licenses = ['MIT']
20 | spec.name = 'invoicexpress'
21 | spec.require_paths = ['lib']
22 | spec.required_rubygems_version = '>= 1.3.6'
23 | spec.summary = spec.description
24 | spec.test_files = Dir.glob("spec/**/*")
25 | spec.version = Invoicexpress::VERSION
26 | end
27 |
--------------------------------------------------------------------------------
/lib/invoicexpress/connection.rb:
--------------------------------------------------------------------------------
1 | require 'faraday_middleware'
2 | require 'faraday/response/parse_xml'
3 | require 'faraday/response/raise_invoicexpress_errors'
4 |
5 | module Invoicexpress
6 | # @private
7 | module Connection
8 | private
9 |
10 | def connection(options={})
11 | klass = options.delete(:klass)
12 |
13 | options = {
14 | #:raw => false,
15 | :ssl => { :verify => false }
16 | }.merge(options)
17 |
18 | if !proxy.nil?
19 | options.merge!(:proxy => proxy)
20 | end
21 |
22 | options.merge!(:params => authentication)
23 |
24 | connection = Faraday.new(options) do |builder|
25 | builder.request :url_encoded
26 |
27 | builder.use FaradayMiddleware::FollowRedirects
28 | builder.use Faraday::Response::ParseXML, klass
29 | builder.use Faraday::Response::RaiseInvoicexpressErrors
30 |
31 | faraday_config_block.call(builder) if faraday_config_block
32 | builder.adapter *adapter
33 | end
34 |
35 | connection.headers[:user_agent] = user_agent
36 | connection
37 | end
38 |
39 | end
40 | end
41 |
--------------------------------------------------------------------------------
/spec/fixtures/invoices.create.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 1503698
4 | draft
5 | Invoice
6 | draft
7 | 18/06/2013
8 | 18/06/2013
9 |
10 | Artigo 16º nº 6 do CIVA.
11 |
12 | http://www.invoicexpress.net/documents/3bca8a616315b1c8da3c26d692b061220f0f6a45
13 |
14 | 501854
15 | Ruben Fonseca
16 |
17 | Euro
18 |
19 | -
20 | Item 1
21 |
22 | 30.0
23 | unit
24 | 1.0
25 |
26 |
27 | 0.0
28 |
29 | 0.0
30 |
31 |
32 | 30.0
33 | 0.0
34 | 30.0
35 | 0.0
36 | 30.0
37 |
38 |
--------------------------------------------------------------------------------
/spec/invoicexpress/client/users_spec.rb:
--------------------------------------------------------------------------------
1 | require 'helper'
2 |
3 | describe Invoicexpress::Client::Clients do
4 |
5 | before do
6 | @client = Invoicexpress::Client.new(:screen_name => "thinkorangeteste")
7 | end
8 |
9 | describe ".login" do
10 | it "logins with your account" do
11 | stub_post("/login.xml").
12 | to_return(xml_response("users.login.xml"))
13 |
14 | list= @client.login("info@test.pt", "2xptopxto")
15 | list.count.should == 1
16 | list.first.name.should == "thinkorangeteste"
17 | end
18 | end
19 |
20 | describe ".accounts" do
21 | it "returns all the accounts" do
22 | stub_get("/users/accounts.xml").
23 | to_return(xml_response("users.accounts.xml"))
24 |
25 | list = @client.accounts
26 | list.count.should == 1
27 | list.first.name.should == "thinkorangeteste"
28 | end
29 | end
30 |
31 | describe ".change-account" do
32 | it "changes the current account to the account id submitted" do
33 | stub_put("/users/change-account.xml").
34 | to_return(xml_response("users.change-account.xml"))
35 |
36 | expect { cnote = @client.change_account(13233) }.to_not raise_error
37 | end
38 | end
39 |
40 | end
41 |
--------------------------------------------------------------------------------
/spec/fixtures/schedules.list.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 4307
5 | 08/04/2013
6 | 08/04/2013
7 |
8 | Foi criado no site.
9 | 5.0
10 |
11 | 439232
12 | Pedro Sousa
13 | psousa@thinkorange.pt
14 | Rua Luisa de Camões 18
15 | 1231-123
16 | 210533382
17 |
18 | Euro
19 |
20 | -
21 | 312260
22 | 555
23 | Macbook
24 | 50.0
25 | 2.0
26 |
27 | 48900
28 | IVA23
29 | 23.0
30 |
31 | 0.0
32 |
33 |
34 | 100.0
35 | 0.0
36 | 100.0
37 | 23.0
38 | 118.0
39 |
40 |
--------------------------------------------------------------------------------
/spec/helper.rb:
--------------------------------------------------------------------------------
1 | require 'simplecov'
2 |
3 | if ENV['COVERAGE']
4 | SimpleCov.start do
5 | add_filter "/spec"
6 | end
7 | end
8 |
9 | require 'invoicexpress'
10 | require 'rspec'
11 | require 'webmock/rspec'
12 |
13 | def stub_get(url)
14 | stub_request(:get, invoicexpress_url(url))
15 | end
16 |
17 | def stub_post(url)
18 | stub_request(:post, invoicexpress_url(url))
19 | end
20 |
21 | def stub_put(url)
22 | stub_request(:put, invoicexpress_url(url))
23 | end
24 |
25 | def stub_delete(url)
26 | stub_request(:delete, invoicexpress_url(url))
27 | end
28 |
29 | def fixture_path
30 | File.expand_path("../fixtures", __FILE__)
31 | end
32 |
33 | def fixture(file)
34 | File.new(fixture_path + "/" + file)
35 | end
36 |
37 | def empty_xml_response
38 | {
39 | :body => "",
40 | :headers => {
41 | :content_type => "application/xml; charset=utf-8"
42 | }
43 | }
44 | end
45 |
46 | def xml_response(file)
47 | {
48 | :body => fixture(file),
49 | :headers => {
50 | :content_type => "application/xml; charset=utf-8"
51 | }
52 | }
53 | end
54 |
55 | def invoicexpress_url(url)
56 | if url =~ /^http/
57 | url
58 | else
59 | "https://thinkorangeteste.app.invoicexpress.com#{url}"
60 | end
61 | end
62 |
63 |
--------------------------------------------------------------------------------
/spec/fixtures/po.get.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 1430276
4 | draft
5 | PurchaseOrder
6 | draft
7 | 30/05/2013
8 | 08/08/2013
9 | 30/05/2013
10 | LX Factory
11 |
12 |
13 | 439232
14 | Pedro Sousa
15 | psousa@thinkorange.pt
16 | Rua Luisa de Camões 18
17 | 1231-123
18 | Portugal
19 | 210533382
20 |
21 | Euro
22 |
23 | -
24 | Item 1
25 |
26 | 60.0
27 | unit
28 | 2.0
29 |
30 | 48900
31 | IVA23
32 | 23.0
33 |
34 | 0.0
35 |
36 |
37 | 120.0
38 | 0.0
39 | 120.0
40 | 27.6
41 | 147.6
42 |
43 |
--------------------------------------------------------------------------------
/spec/fixtures/po.create.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 1430276
4 | draft
5 | PurchaseOrder
6 | draft
7 | 30/05/2013
8 | 08/08/2013
9 | 30/05/2013
10 | LX Factory
11 |
12 |
13 | 439232
14 | Pedro Sousa
15 | psousa@thinkorange.pt
16 | Rua Luisa de Camões 18
17 | 1231-123
18 | Portugal
19 | 210533382
20 |
21 | Euro
22 |
23 | -
24 | Item 1
25 |
26 | 60.0
27 | unit
28 | 2.0
29 |
30 | 48900
31 | IVA23
32 | 23.0
33 |
34 | 0.0
35 |
36 |
37 | 120.0
38 | 0.0
39 | 120.0
40 | 27.6
41 | 147.6
42 |
43 |
--------------------------------------------------------------------------------
/lib/invoicexpress/models/quarterly_result.rb:
--------------------------------------------------------------------------------
1 | module Invoicexpress
2 | module Models
3 |
4 | #TODO Improve this in the future, maybe inherit
5 | class Quarter01 < BaseModel
6 | include HappyMapper
7 | tag 'quarter-01'
8 | element :invoicing, Float
9 | element :taxes, Float
10 | element :ytd, Float
11 | end
12 | class Quarter02 < BaseModel
13 | include HappyMapper
14 | tag 'quarter-02'
15 | element :invoicing, Float
16 | element :taxes, Float
17 | element :ytd, Float
18 | end
19 | class Quarter03 < BaseModel
20 | include HappyMapper
21 | tag 'quarter-03'
22 | element :invoicing, Float
23 | element :taxes, Float
24 | element :ytd, Float
25 | end
26 | class Quarter04 < BaseModel
27 | include HappyMapper
28 | tag 'quarter-04'
29 | element :invoicing, Float
30 | element :taxes, Float
31 | element :ytd, Float
32 | end
33 |
34 | class QuarterlyResult < BaseModel
35 | include HappyMapper
36 | tag 'quarterly-results'
37 | element :year, Integer
38 | element :currency, String
39 | has_one :quarter01, Quarter01
40 | has_one :quarter02, Quarter02
41 | has_one :quarter03, Quarter03
42 | has_one :quarter04, Quarter04
43 | end
44 | end
45 | end
--------------------------------------------------------------------------------
/lib/invoicexpress/configuration.rb:
--------------------------------------------------------------------------------
1 | require 'faraday'
2 | require 'invoicexpress/version'
3 |
4 | module Invoicexpress
5 | module Configuration
6 | VALID_OPTIONS_KEYS = [
7 | :adapter,
8 | :faraday_config_block,
9 | :api_endpoint,
10 | :screen_name,
11 | :proxy,
12 | :api_key,
13 | :user_agent
14 | ].freeze
15 |
16 | DEFAULT_ADAPTER = Faraday.default_adapter
17 | DEFAULT_API_ENDPOINT = ENV['INVOICEXPRESS_API_ENDPOINT'] || 'https://%s.app.invoicexpress.com/'
18 | DEFAULT_USER_AGENT = "Invoicexpress Ruby Gem #{Invoicexpress::VERSION}".freeze
19 |
20 | attr_accessor(*VALID_OPTIONS_KEYS)
21 |
22 | def self.extended(base)
23 | base.reset
24 | end
25 |
26 | def configure
27 | yield self
28 | end
29 |
30 | def options
31 | VALID_OPTIONS_KEYS.inject({}) { |o,k| o.merge!(k => send(k)) }
32 | end
33 |
34 | def api_endpoint=(value)
35 | @api_endpoint = File.join(value, "")
36 | end
37 |
38 | def faraday_config(&block)
39 | @faraday_config_block = block
40 | end
41 |
42 | def reset
43 | self.adapter = DEFAULT_ADAPTER
44 | self.api_endpoint = DEFAULT_API_ENDPOINT
45 | self.user_agent = DEFAULT_USER_AGENT
46 | self.api_key = nil
47 | self.screen_name = nil
48 | self.proxy = nil
49 | end
50 | end
51 | end
52 |
--------------------------------------------------------------------------------
/spec/fixtures/schedules.create.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4462
4 | 16/08/2013
5 | 16/08/2013
6 |
7 |
8 |
9 |
10 | Rui Leito
11 | rmleitao@thinkorange.pt
12 |
13 |
14 |
15 |
16 | Euro
17 |
18 | -
19 | 288911
20 | Item 1
21 |
22 | 30.0
23 | 2.0
24 |
25 | IVA23
26 | 23.0
27 |
28 | 0.0
29 |
30 | -
31 | 288781
32 | Item 2
33 |
34 | 60.0
35 | 5.0
36 |
37 | IVA23
38 | 23.0
39 |
40 | 0.0
41 |
42 |
43 | 360.0
44 | 0.0
45 | 360.0
46 | 82.8
47 | 442.8
48 |
49 |
--------------------------------------------------------------------------------
/spec/fixtures/po.list.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 1430276
5 | draft
6 | PurchaseOrder
7 | draft
8 | 30/05/2013
9 | 08/08/2013
10 | 30/05/2013
11 | LX Factory
12 |
13 |
14 | 439232
15 | Pedro Sousa
16 | psousa@thinkorange.pt
17 | Rua Luisa de Camões 18
18 | 1231-123
19 | Portugal
20 | 210533382
21 |
22 | Euro
23 |
24 | -
25 | Item 1
26 |
27 | 60.0
28 | unit
29 | 2.0
30 |
31 | 48900
32 | IVA23
33 | 23.0
34 |
35 | 0.0
36 |
37 |
38 | 120.0
39 | 0.0
40 | 120.0
41 | 27.6
42 | 147.6
43 |
44 |
--------------------------------------------------------------------------------
/lib/invoicexpress/models/filter.rb:
--------------------------------------------------------------------------------
1 | module Invoicexpress
2 | module Models
3 | class FilterStatus < BaseModel
4 | include HappyMapper
5 |
6 | tag 'status'
7 | has_many :options, String, :tag => 'option'
8 | end
9 |
10 | class FilterByType < BaseModel
11 | include HappyMapper
12 |
13 | tag 'by_type'
14 | has_many :options, String, :tag => 'option'
15 | end
16 |
17 | class FilterArchived < BaseModel
18 | include HappyMapper
19 |
20 | tag 'archived'
21 | has_many :options, String, :tag => 'option'
22 | end
23 |
24 | class Filter < BaseModel
25 | include HappyMapper
26 |
27 | tag 'filter'
28 | element :status, FilterStatus
29 | element :by_type, FilterByType
30 | element :archived, FilterArchived
31 |
32 | def initialize(args = {})
33 | if args[:status] && args[:status].is_a?(Array)
34 | o = FilterStatus.new
35 | o.options = []
36 | o.options = args[:status].map(&:to_s)
37 |
38 | self.status = o
39 | end
40 |
41 | if args[:by_type] && args[:by_type].is_a?(Array)
42 | o = FilterByType.new
43 | o.options = []
44 | o.options = args[:by_type].map(&:to_s)
45 |
46 | self.by_type = o
47 | end
48 |
49 | if args[:archived] && args[:archived].is_a?(Array)
50 | o = FilterArchived.new
51 | o.options = []
52 | o.options = args[:archived].map(&:to_s)
53 |
54 | self.archived = o
55 | end
56 |
57 | end
58 | end
59 | end
60 | end
61 |
--------------------------------------------------------------------------------
/spec/fixtures/invoices.get.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 1503698
4 | draft
5 | false
6 | Invoice
7 | draft
8 | 18/06/2013
9 | 18/06/2013
10 |
11 | Artigo 16º nº 6 do CIVA.
12 |
13 | http://www.invoicexpress.net/documents/3bca8a616315b1c8da3c26d692b061220f0f6a45
14 |
15 | 501854
16 | Ruben Fonseca
17 |
18 | Euro
19 |
20 | -
21 | Item 1
22 |
23 | 30.0
24 | unit
25 | 1.0
26 |
27 |
28 | 0.0
29 |
30 | 0.0
31 | 30.0
32 | 0.0
33 | 0.0
34 | 30.0
35 |
36 |
37 | 30.0
38 | 0.0
39 | 30.0
40 | 0.0
41 | 30.0
42 |
43 |
44 | create
45 | 20/06/2013
46 |
47 | info@thinkorange.pt
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/spec/fixtures/charts.treasury.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Jan
4 | Fev
5 | Mar
6 | Abr
7 | Mai
8 | Jun
9 | Jul
10 |
11 |
12 |
13 | 0
14 | 0
15 | 0
16 | 0
17 | 0
18 | 0
19 | 0
20 |
21 |
22 | 0
23 | 0
24 | 0
25 | 0
26 | 0
27 | 0
28 | 0
29 |
30 |
31 | 0
32 | 60
33 | 0
34 | 0
35 | 0
36 | 0
37 | 0
38 |
39 |
40 | 0
41 | 60
42 | 0
43 | 0
44 | 0
45 | 0
46 | 0
47 |
48 |
49 |
--------------------------------------------------------------------------------
/spec/fixtures/credit_notes.create.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 1423940
4 | draft
5 | CreditNote
6 | draft
7 | 01/05/2013
8 | 01/06/2013
9 |
10 | Artigo 16º nº 6 do CIVA.
11 |
12 |
13 | 439232
14 | Pedro Sousa
15 | psousa@thinkorange.pt
16 | Rua Luisa de Camões 18
17 | 1231-123
18 | Portugal
19 | 210533382
20 |
21 | Euro
22 |
23 | -
24 | Item 1
25 |
26 | 60.0
27 | unit
28 | 2.0
29 |
30 |
31 | 0.0
32 |
33 | 0.0
34 |
35 | -
36 | Item 2
37 |
38 | 50.0
39 | unit
40 | 1.0
41 |
42 |
43 | 0.0
44 |
45 | 0.0
46 |
47 |
48 | 170.0
49 | 0.0
50 | 170.0
51 | 0.0
52 | 170.0
53 |
54 |
--------------------------------------------------------------------------------
/spec/fixtures/schedules.get.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4462
4 | 16/08/2013
5 | 17/08/2013
6 | 16/08/2013
7 | 16/08/2013
8 | 16/06/2013
9 | 18/08/2013
10 |
11 |
12 |
13 |
14 | 501506
15 | Rui Leito
16 | rmleitao@thinkorange.pt
17 |
18 |
19 |
20 |
21 | Euro
22 |
23 | -
24 | 288911
25 | Item 1
26 |
27 | 30.0
28 | 2.0
29 |
30 | 48900
31 | IVA23
32 | 23.0
33 |
34 | 0.0
35 |
36 | -
37 | 288781
38 | Item 2
39 |
40 | 60.0
41 | 5.0
42 |
43 | 48900
44 | IVA23
45 | 23.0
46 |
47 | 0.0
48 |
49 |
50 | 360.0
51 | 0.0
52 | 360.0
53 | 82.8
54 | 442.8
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/spec/fixtures/simplified_invoices.create.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 1425061
4 | draft
5 | SimplifiedInvoice
6 | draft
7 | 01/05/2013
8 |
9 | Artigo 16º nº 6 do CIVA.
10 |
11 | http://www.invoicexpress.net/documents/9c21e2aa2fd5a9f999673bc993407a562177fecb
12 |
13 | 439232
14 | Pedro Sousa
15 | psousa@thinkorange.pt
16 | Rua Luisa de Camões 18
17 | 1231-123
18 | Portugal
19 | 210533382
20 |
21 | Euro
22 |
23 | -
24 | Item 1
25 |
26 | 60.0
27 | unit
28 | 2.0
29 |
30 |
31 | 0.0
32 |
33 | 0.0
34 |
35 | -
36 | Item 2
37 |
38 | 50.0
39 | unit
40 | 1.0
41 |
42 |
43 | 0.0
44 |
45 | 0.0
46 |
47 |
48 | 170.0
49 | 0.0
50 | 170.0
51 | 0.0
52 | 170.0
53 |
54 |
--------------------------------------------------------------------------------
/doc/yard/file_list.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
27 |
28 |
29 |
44 |
Search:
45 |
46 |
47 |
48 |
49 | - README
50 |
51 |
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # invoiceXpress GEM
2 |
3 | [](http://badge.fury.io/rb/invoicexpress) [](https://travis-ci.org/weareswat/invoicexpress-gem) [](https://codeclimate.com/github/weareswat/invoicexpress-gem)
4 |
5 | Gem for invoicexpress API at http://invoicexpress.com
6 | Created with Reference: http://en.invoicexpress.com/api/overview/introduction/
7 |
8 | ## Dependencies
9 |
10 | Run bundle, the project should need:
11 | * Invoicexpress API Key
12 | * Happymapper
13 | * Faraday
14 | * And pretzels!
15 |
16 | ## Progress
17 |
18 | * Client - 100%
19 | * Sequences - 100%
20 | * Users - 100%
21 | * Invoices - 100%
22 | * Cash Invoices - 100%
23 | * Items - 100%
24 | * Charts - 100%
25 | * Debit Notes - 100%
26 | * Credit Notes - 100%
27 | * Taxes - 100%
28 | * Schedules - 100%
29 | * Sim. Invoices - 100%
30 | * Purch. Orders - 100%
31 |
32 | ## Tests
33 |
34 | * Client - 100%
35 | * Sequences - 100%
36 | * Users - 100%
37 | * Charts - 100%
38 | * Taxes - 100%
39 | * Schedules - 100%
40 | * Invoices - 100%
41 | * Sim. Invoices - 100%
42 | * Credit Notes - 100%
43 | * Purch. Orders - 100%
44 |
45 | ## Documentation
46 |
47 | We've included docs for all methods. Refer to the doc folder and client section.
48 |
49 | ## Examples
50 |
51 | If using from inside a rails project use:
52 |
53 | require 'invoicexpress'
54 |
55 | client = Invoicexpress::Client.new(
56 | :screen_name => "yourusername",
57 | :api_key => "yourapikey"
58 | )
59 |
60 | Examples for API are located in the EXAMPLES.md file.
61 |
62 |
--------------------------------------------------------------------------------
/lib/invoicexpress/error.rb:
--------------------------------------------------------------------------------
1 | require 'happymapper'
2 |
3 | module Invoicexpress
4 | module Models
5 | class Errors
6 | include HappyMapper
7 |
8 | has_many :error, String
9 | alias :errors :error
10 | end
11 | end
12 |
13 | # Custom error class for rescuing from all Invoicexpress errors
14 | #
15 | class Error < StandardError
16 | attr_accessor :messages
17 |
18 | def initialize(response=nil)
19 | @response = response
20 | @messages = []
21 |
22 | super(build_error_message)
23 | end
24 |
25 | def response_body
26 | @response_body ||=
27 | if (body = @response[:body]) && !body.empty?
28 | if body.is_a?(String) and body.start_with?("<")
29 | Invoicexpress::Models::Errors.parse(body)
30 | else
31 | body
32 | end
33 | else
34 | nil
35 | end
36 | end
37 |
38 | private
39 |
40 | def build_error_message
41 | return nil if @response.nil?
42 |
43 | message = if response_body
44 | if response_body.respond_to?(:errors)
45 | ": " + response_body.errors.join(", ")
46 | else
47 | ": " + response_body
48 | end
49 | else
50 | ''
51 | end
52 |
53 | "#{@response[:method].to_s.upcase} #{@response[:url].to_s}: #{@response[:status]}#{message}"
54 | end
55 | end
56 |
57 | # Raised when Invoicexpress returns a 401 HTTP status code
58 | class Unauthorized < Error; end
59 |
60 | # Raised when Invoicexpress returns a 404 HTTP status code
61 | class NotFound < Error; end
62 |
63 | # Raised when Invoicexpress returns a 422 HTTP status code
64 | class UnprocessableEntity < Error; end
65 |
66 | # Raised when Invoicexpress server goes dark (500 HTTP status code)
67 | class InternalServerError < Error; end
68 | end
69 |
--------------------------------------------------------------------------------
/lib/invoicexpress/request.rb:
--------------------------------------------------------------------------------
1 | module Invoicexpress
2 | module Request
3 |
4 | def delete(path, options={})
5 | request(:delete, path, options).body
6 | end
7 |
8 | def get(path, options={})
9 | repsonse = request(:get, path, options).body
10 | end
11 |
12 | def patch(path, options={})
13 | request(:patch, path, options).body
14 | end
15 |
16 | def post(path, options={})
17 | request(:post, path, options).body
18 | end
19 |
20 | def put(path, options={})
21 | request(:put, path, options).body
22 | end
23 |
24 | private
25 |
26 | # Executes the request, checking if ti was successful
27 | #
28 | # @return [Boolean] True on success, false otherwise
29 | def boolean_from_response(method, path, options={})
30 | request(method, path, options).status == 204
31 | rescue Invoicexpress::NotFound
32 | false
33 | end
34 |
35 | def request(method, path, options={})
36 | token = options.delete(:api_key) || api_key
37 | url = options.delete(:endpoint) || (api_endpoint % screen_name)
38 | klass = options.delete(:klass) || raise(ArgumentError, "Need a HappyMapper class to parse")
39 |
40 | conn_options = {
41 | :url => url,
42 | :klass => klass
43 | }
44 |
45 | response = connection(conn_options).send(method) do |request|
46 | request.headers['Accept'] = options.delete(:accept) || 'application/xml'
47 |
48 | case method
49 | when :get, :delete, :head
50 | request.url(path, options)
51 | when :patch, :post, :put
52 | request.headers['Content-Type'] = "application/xml; charset=utf-8"
53 |
54 | request.path = path
55 | request.body = options[:body].to_xml unless options.empty?
56 | end
57 | end
58 |
59 | response
60 | end
61 |
62 | end
63 | end
64 |
--------------------------------------------------------------------------------
/spec/invoicexpress/client/taxes_spec.rb:
--------------------------------------------------------------------------------
1 | require 'helper'
2 |
3 | describe Invoicexpress::Client::Taxes do
4 | before do
5 | @client = Invoicexpress::Client.new(:screen_name => "thinkorangeteste")
6 | end
7 |
8 | describe ".taxes" do
9 | it "Returns all the taxes" do
10 | stub_get("/taxes.xml").
11 | to_return(xml_response("taxes.list.xml"))
12 |
13 | taxes = @client.taxes
14 | taxes.count.should == 2
15 | end
16 | end
17 |
18 | describe ".create_tax" do
19 | it "creates a new tax" do
20 | stub_post("/taxes.xml").
21 | to_return(xml_response("taxes.create.xml"))
22 |
23 | model_tax = Invoicexpress::Models::Tax.new({
24 | :name => "IVA19",
25 | :value => 19.0,
26 | :region => "PT",
27 | :default_tax => 1
28 | })
29 |
30 | tax = @client.create_tax(model_tax)
31 | tax.name.should == "IVA19"
32 | tax.value.should == 19.0
33 | tax.region.should == "PT"
34 | tax.default_tax.should == 1
35 | end
36 |
37 | it "raises if no tax is passed" do
38 | expect {
39 | @client.create_tax(nil)
40 | }.to raise_error(ArgumentError)
41 | end
42 | end
43 |
44 | describe ".update_tax" do
45 | it "updates a tax" do
46 | stub_put("/taxes/123.xml").
47 | to_return(xml_response("taxes.update.xml"))
48 |
49 | model = Invoicexpress::Models::Tax.new({
50 | :id => 123,
51 | :name => "IVA23",
52 | :value => 23.0
53 | })
54 |
55 | tax = @client.update_tax(model)
56 | tax.name.should == "IVA23"
57 | tax.value.should == 23.0
58 | tax.region.should == "PT"
59 | end
60 | end
61 |
62 | describe ".delete_tax" do
63 | it "should delete a tax without errors" do
64 | stub_delete("/taxes/123.xml").to_return(empty_xml_response)
65 |
66 | expect { @client.delete_tax(123) }.to_not raise_error
67 | end
68 | end
69 |
70 | end
71 |
--------------------------------------------------------------------------------
/lib/invoicexpress/client.rb:
--------------------------------------------------------------------------------
1 | require 'invoicexpress/authentication'
2 | require 'invoicexpress/connection'
3 | require 'invoicexpress/request'
4 |
5 | require 'invoicexpress/models'
6 |
7 | require 'invoicexpress/client/clients'
8 | require 'invoicexpress/client/invoices'
9 | require 'invoicexpress/client/cash_invoices'
10 | require 'invoicexpress/client/items'
11 | require 'invoicexpress/client/sequences'
12 | require 'invoicexpress/client/users'
13 | require 'invoicexpress/client/charts'
14 | require 'invoicexpress/client/taxes'
15 | require 'invoicexpress/client/schedules'
16 | require 'invoicexpress/client/purchase_orders'
17 | require 'invoicexpress/client/debit_notes'
18 | require 'invoicexpress/client/credit_notes'
19 | require 'invoicexpress/client/simplified_invoices'
20 |
21 |
22 | module Invoicexpress
23 | # Please refer to each section inside the client for the respective documentation.
24 | #
25 | #
26 | class Client
27 | attr_accessor(*Configuration::VALID_OPTIONS_KEYS)
28 |
29 | def initialize(options={})
30 | options = Invoicexpress.options.merge(options)
31 | Configuration::VALID_OPTIONS_KEYS.each do |key|
32 | send("#{key}=", options[key])
33 | end
34 | end
35 |
36 | include Invoicexpress::Authentication
37 | include Invoicexpress::Connection
38 | include Invoicexpress::Request
39 |
40 | include Invoicexpress::Client::Clients
41 | include Invoicexpress::Client::Invoices
42 | include Invoicexpress::Client::CashInvoices
43 | include Invoicexpress::Client::Items
44 | include Invoicexpress::Client::Sequences
45 | include Invoicexpress::Client::Users
46 | include Invoicexpress::Client::Charts
47 | include Invoicexpress::Client::Taxes
48 | include Invoicexpress::Client::Schedules
49 |
50 | include Invoicexpress::Client::PurchaseOrders
51 | include Invoicexpress::Client::DebitNotes
52 | include Invoicexpress::Client::CreditNotes
53 | include Invoicexpress::Client::SimplifiedInvoices
54 |
55 | end
56 | end
57 |
--------------------------------------------------------------------------------
/lib/invoicexpress/client/users.rb:
--------------------------------------------------------------------------------
1 | module Invoicexpress
2 | class Client
3 | module Users
4 |
5 | # This endpoint does not require an API KEY to be acessible.
6 | # Instead it requires your current login and password.
7 | # Upon successful login it will return all the accounts which belong to you
8 | #
9 | # @param login [String] Login email
10 | # @param password [String] Your password
11 | # @return [Array] The list of your accounts
12 | # @raise Invoicexpress::Unauthorized When the login/password combination is wrong
13 | def login(login, password, options={})
14 | credentials = Invoicexpress::Models::Credentials.new(
15 | :login => login,
16 | :password => password
17 | )
18 |
19 | params = { :klass => Invoicexpress::Models::Account, :body => credentials }
20 | post("login.xml", params.merge(options))
21 | end
22 |
23 | # This method allows you to view your accounts.
24 | #
25 | # @raise Invoicexpress::Unauthorized When the client is unauthorized
26 | # @return [Array] The list of accounts
27 | def accounts(options = {})
28 | params = { :klass => Invoicexpress::Models::Account }
29 | get("users/accounts.xml", params.merge(options))
30 | end
31 |
32 | # Changes the current account to the account id submitte
33 | #
34 | # @param account_id [String] The account ID to change to
35 | # @raise Invoicexpress::Unauthorized When the client is unauthorized
36 | # @raise Invoicexpress::NotFound When the account doesn't exist
37 | def change_account(account_id, options={})
38 | change_account_to = Invoicexpress::Models::ChangeAccountTo.new(
39 | :id => account_id
40 | )
41 |
42 | params = { :klass => Invoicexpress::Models::Account, :body => change_account_to }
43 | put("users/change-account.xml", params.merge(options))
44 | end
45 |
46 | end
47 | end
48 | end
49 |
--------------------------------------------------------------------------------
/spec/invoicexpress/client/sequences_spec.rb:
--------------------------------------------------------------------------------
1 | require 'helper'
2 |
3 | describe Invoicexpress::Client::Sequences do
4 | before do
5 | @client = Invoicexpress::Client.new(:screen_name => "thinkorangeteste")
6 | end
7 |
8 | describe ".sequences" do
9 | it "Returns all the sequences" do
10 | stub_get("/sequences.xml").
11 | to_return(xml_response("sequences.list.xml"))
12 |
13 | list = @client.sequences
14 | list.count.should == 1
15 | list.first.id == 230568
16 | list.first.current_invoice_number==1
17 | end
18 | end
19 |
20 | describe ".sequence" do
21 | it "gets a sequence" do
22 | stub_get("/sequences/230568.xml").
23 | to_return(xml_response("sequences.get.xml"))
24 |
25 | c = @client.sequence(230568)
26 | c.id.should == "230568"
27 | c.serie.should == "2013"
28 | end
29 | end
30 |
31 | describe ".create_sequence" do
32 | it "creates a new sequence" do
33 | stub_post("/sequences.xml").
34 | to_return(xml_response("sequences.create.xml"))
35 |
36 | seq = Invoicexpress::Models::Sequence.new({
37 | :serie => "2099",
38 | :current_invoice_number => 100,
39 | :current_credit_note_number => 200,
40 | :current_debit_note_number => 300,
41 | :default_sequence => 0
42 | })
43 |
44 | new_object = @client.create_sequence(seq)
45 | new_object.serie.should == "2099"
46 | new_object.current_invoice_number.should == 100
47 | end
48 | end
49 |
50 | describe ".update_sequence" do
51 | it "updates the sequence" do
52 | stub_put("/sequences/266500.xml").
53 | to_return(xml_response("sequences.update.xml"))
54 |
55 | model = Invoicexpress::Models::Sequence.new({
56 | :id=>'266500',
57 | :serie => "2098",
58 | :current_invoice_number => 100,
59 | :current_credit_note_number => 200,
60 | :current_debit_note_number => 300,
61 | :default_sequence => 0
62 | })
63 |
64 | expect { @client.update_sequence(model) }.to_not raise_error
65 | end
66 | end
67 | end
68 |
69 |
--------------------------------------------------------------------------------
/spec/invoicexpress/client/charts_spec.rb:
--------------------------------------------------------------------------------
1 | require 'helper'
2 |
3 | describe Invoicexpress::Client::Charts do
4 |
5 | before do
6 | @client = Invoicexpress::Client.new(:screen_name => "thinkorangeteste")
7 | end
8 |
9 | describe ".invoicing_chart" do
10 | it "Returns the invoicing chart data." do
11 | stub_get("/api/charts/invoicing.xml").
12 | to_return(xml_response("charts.invoicing.xml"))
13 |
14 | chart = @client.invoicing_chart
15 | chart.series.values.count.should == 6
16 | chart.graphs.first.values.count.should == 6
17 | end
18 | end
19 |
20 | describe ".treasury_chart" do
21 | it "Returns the treasury chart data." do
22 | stub_get("/api/charts/treasury.xml").
23 | to_return(xml_response("charts.treasury.xml"))
24 |
25 | chart = @client.treasury_chart
26 | #all there
27 | chart.series.values.count.should == 7
28 | #4 graphs
29 | chart.graphs.count.should ==4
30 | #count values
31 | chart.graphs.first.values.count.should ==7
32 |
33 | end
34 | end
35 |
36 | describe ".top_clients" do
37 | it "Returns the top 5 clients." do
38 | stub_get("/api/charts/top-clients.xml").
39 | to_return(xml_response("charts.top-clients.xml"))
40 |
41 | chart = @client.top_clients
42 | chart.clients.first.name.should =="Ruben Fonseca"
43 | chart.clients.size.should ==1
44 | end
45 | end
46 |
47 | describe ".top_debtors" do
48 | it "Returns the top 5 debtors." do
49 | stub_get("/api/charts/top-debtors.xml").
50 | to_return(xml_response("charts.top-debtors.xml"))
51 |
52 | chart = @client.top_debtors
53 | chart.clients.size.should ==1
54 | chart.clients.first.name.should =="Ruben Fonseca"
55 | end
56 | end
57 |
58 | describe ".quarterly_results" do
59 | it "return all the quarterly results." do
60 | stub_get("/api/charts/quarterly-results.xml?year=2010").
61 | to_return(xml_response("charts.quarterly-results.xml"))
62 |
63 | list = @client.quarterly_results(2010)
64 | list.quarter01.invoicing.should ==60.0
65 | list.year.should ==2010
66 | end
67 | end
68 |
69 | end
70 |
--------------------------------------------------------------------------------
/lib/invoicexpress/models/purchase_order.rb:
--------------------------------------------------------------------------------
1 | require 'invoicexpress/models/invoice'
2 | require 'invoicexpress/models/supplier'
3 | require 'invoicexpress/models/client'
4 |
5 | module Invoicexpress
6 | module Models
7 |
8 | module BasePurchaseOrder
9 | def self.included(base)
10 | base.class_eval do
11 | include HappyMapper
12 |
13 | tag 'purchase_order'
14 | element :id, Integer
15 | element :date, Date, :on_save => DATE_FORMAT
16 | element :due_date, Date, :on_save => DATE_FORMAT
17 | element :loaded_at, Date, :on_save => DATE_FORMAT
18 | element :observations, String
19 | element :delivery_site, String
20 | has_one :supplier, Supplier
21 | has_one :client, Client
22 | has_many :items, Item, :on_save => Proc.new { |value|
23 | Items.new(:items => value)
24 | }
25 | end
26 | end
27 | end
28 |
29 | class CorePurchaseOrder < BaseModel
30 | include BasePurchaseOrder
31 | #tag 'purchase_order'
32 | end
33 |
34 | class PurchaseOrder < CorePurchaseOrder
35 | include BasePurchaseOrder
36 | #include HappyMapper
37 | #tag 'purchase_order'
38 |
39 | element :status, String
40 | element :sequence_number, String
41 | element :permalink, String
42 | element :currency, String
43 |
44 |
45 | element :sum, Float
46 | element :discount, Float
47 | element :before_taxes, Float
48 | element :taxes, Float
49 | element :total, Float
50 |
51 | def to_core_purchase_order()
52 | Invoicexpress::Models::CorePurchaseOrder.new(
53 | :id=>self.id,
54 | :date=>self.date,
55 | :due_date=>self.due_date,
56 | :loaded_at=>self.loaded_at,
57 | :observations=>self.observations,
58 | :delivery_site=>self.delivery_site,
59 | :supplier=>self.supplier,
60 | :client=>self.client,
61 | :items=>self.items
62 | )
63 | end
64 | end
65 |
66 | class PurchaseOrders < BaseModel
67 | include HappyMapper
68 | tag 'purchase_orders'
69 | has_many :purchase_orders, PurchaseOrder
70 | end
71 | end
72 | end
--------------------------------------------------------------------------------
/spec/fixtures/simplified_invoices.get.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 1425061
4 | settled
5 | false
6 | SimplifiedInvoice
7 | 1/2013
8 | 01/05/2013
9 |
10 | Artigo 16º nº 6 do CIVA.
11 |
12 | http://www.invoicexpress.net/documents/9c21e2aa2fd5a9f999673bc993407a562177fecb
13 |
14 | 550611
15 | Pedro Sousa
16 | psousa@thinkorange.pt
17 | Rua Luisa de Camões 18
18 | 1231-123
19 | Portugal
20 | 210533382
21 |
22 | Euro
23 |
24 | -
25 | Item 1
26 |
27 | 60.0
28 | unit
29 | 2.0
30 |
31 |
32 | 0.0
33 |
34 | 0.0
35 |
36 | -
37 | Item 2
38 |
39 | 50.0
40 | unit
41 | 1.0
42 |
43 |
44 | 0.0
45 |
46 | 0.0
47 |
48 |
49 | 170.0
50 | 0.0
51 | 170.0
52 | 0.0
53 | 170.0
54 |
55 |
56 | create
57 | 30/05/2013
58 |
59 | info@thinkorange.pt
60 |
61 |
62 | finalized
63 | 30/05/2013
64 |
65 | info@thinkorange.pt
66 |
67 |
68 | created_partial_payment
69 | 30/05/2013
70 |
71 | info@thinkorange.pt
72 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/lib/invoicexpress/models/schedule.rb:
--------------------------------------------------------------------------------
1 | require 'invoicexpress/models/client'
2 | require 'invoicexpress/models/invoice'
3 |
4 | module Invoicexpress
5 | module Models
6 |
7 | class InvoiceTemplate < BaseModel
8 | include BaseInvoice
9 | tag 'invoice_template'
10 | element :due_days, Integer
11 | end
12 |
13 | class SentInvoices < BaseModel
14 | include HappyMapper
15 | tag 'sent_invoices'
16 | has_many :invoices, Invoice
17 | end
18 |
19 | module BaseSchedule
20 | def self.included(base)
21 | base.class_eval do
22 | include HappyMapper
23 | tag 'schedule'
24 |
25 | element :id, Integer
26 | #these fields are only used on create and update...
27 | element :start_date, Date, :on_save => DATE_FORMAT
28 | element :end_date, Date, :on_save => DATE_FORMAT
29 | element :create_back, String
30 | element :schedule_type, String
31 | element :interval, String
32 | element :send_to_client, String
33 | element :description, String
34 |
35 | # has_many :sent_invoices, Invoice
36 | has_one :invoice_template, InvoiceTemplate
37 |
38 | end
39 | end
40 | end
41 |
42 | class CoreSchedule < BaseModel
43 | include BaseSchedule
44 | end
45 |
46 | class Schedule < CoreSchedule
47 | include BaseSchedule
48 |
49 | element :reference, String
50 | element :retention, Float
51 | element :currency, String
52 | #observation instead of description?
53 | element :observations, String
54 | #items and client instead of invoice template?
55 | has_many :items, Item
56 | has_one :client, Client
57 | element :sum, Float
58 | element :discount, Float
59 | element :before_taxes, Float
60 | element :taxes, Float
61 | element :total, Float
62 | has_one :sent_invoices, SentInvoices
63 |
64 | #creates a object that can be used in create/update by the invoicexpress API
65 | def to_core_schedule()
66 | Invoicexpress::Models::CoreSchedule.new(
67 | :id=>self.id,
68 | :start_date=>self.start_date,
69 | :end_date=>self.end_date,
70 | :create_back=>self.create_back,
71 | :schedule_type=>self.schedule_type,
72 | :interval=>self.interval,
73 | :send_to_client=>self.send_to_client,
74 | :description=>self.description,
75 | :invoice_template=>self.invoice_template
76 | )
77 | end
78 | end
79 |
80 | class Schedules < BaseModel
81 | include HappyMapper
82 | tag 'schedules'
83 | has_many :schedules, Schedule
84 | end
85 | end
86 | end
87 |
88 |
--------------------------------------------------------------------------------
/lib/invoicexpress/client/charts.rb:
--------------------------------------------------------------------------------
1 | module Invoicexpress
2 | class Client
3 | module Charts
4 |
5 | # Returns the invoicing chart data.
6 | #
7 | # @return [Array] An array with all the charting results
8 | # @raise Invoicexpress::Unauthorized When the client is unauthorized
9 | def invoicing_chart(options = {})
10 | params = { :klass => Invoicexpress::Models::Chart }
11 | get("api/charts/invoicing.xml", params.merge(options))
12 | end
13 |
14 | # Returns the treasury chart data.
15 | #
16 | # @return [Array] An array with all the charting results
17 | # @raise Invoicexpress::Unauthorized When the client is unauthorized
18 | def treasury_chart(options = {})
19 | params = { :klass => Invoicexpress::Models::Chart }
20 | get("api/charts/treasury.xml", params.merge(options))
21 | end
22 |
23 | # Returns your 5 top clients for which you have invoiced more.
24 | #
25 | # @return [Array] An array with all the charting results
26 | # @raise Invoicexpress::Unauthorized When the client is unauthorized
27 | def top_clients(options = {})
28 | params = { :klass => Invoicexpress::Models::TopClient }
29 | get("api/charts/top-clients.xml", params.merge(options))
30 | end
31 |
32 | # Returns your 5 top debtors. Values are calculated based on the due amount.
33 | #
34 | # @return [Array] An array with all the charting results
35 | # @raise Invoicexpress::Unauthorized When the client is unauthorized
36 | def top_debtors(options = {})
37 | params = { :klass => Invoicexpress::Models::TopDebtor }
38 | get("api/charts/top-debtors.xml", params.merge(options))
39 | end
40 |
41 | # This method allows you to obtain the quarterly results.
42 | # Each quarter has:
43 | # The amount invoiced before taxes
44 | # Taxes amount
45 | # Year to date (YTD) which consists on the difference between the invoiced on the current quarter less the invoiced on the same quarter one year ago
46 | #
47 | # @param year [Integer] By default year is the current year. It should obey the format YYYY (ex.: 2010)
48 | # @return [Array] An array with all the charting results
49 | # @raise Invoicexpress::Unauthorized When the client is unauthorized
50 | def quarterly_results(year=Date.today.year , options = {})
51 | #params = { :klass => Invoicexpress::Models::QuaterlyResult }
52 | params = { :klass => Invoicexpress::Models::QuarterlyResult, :year => year }
53 | get("api/charts/quarterly-results.xml", params.merge(options))
54 | end
55 | end
56 | end
57 | end
58 |
--------------------------------------------------------------------------------
/doc/yard/top-level-namespace.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 | Top Level Namespace
8 |
9 | — Documentation by YARD 0.8.5
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
63 |
64 |
65 |
66 | Top Level Namespace
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
Defined Under Namespace
85 |
86 |
87 |
88 | Modules: Faraday, Invoicexpress
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
110 |
111 |
112 |
--------------------------------------------------------------------------------
/doc/yard/Invoicexpress/Connection.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 | Module: Invoicexpress::Connection
8 |
9 | — Documentation by YARD 0.8.5
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
63 |
64 |
65 |
66 | Module: Invoicexpress::Connection
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | - Included in:
81 | - Client
82 |
83 |
84 |
85 | - Defined in:
86 | - lib/invoicexpress/connection.rb
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
107 |
108 |
109 |
--------------------------------------------------------------------------------
/lib/invoicexpress/client/sequences.rb:
--------------------------------------------------------------------------------
1 | module Invoicexpress
2 | class Client
3 | module Sequences
4 |
5 | # Returns all your sequences.
6 | #
7 | # @return [Array] An array with all the sequences
8 | # @raise Invoicexpress::Unauthorized When the client is unauthorized
9 | def sequences(options = {})
10 | params = { :klass => Invoicexpress::Models::Sequence }
11 |
12 | get("sequences.xml", params.merge(options))
13 | end
14 |
15 | # Returns a specific sequence.
16 | #
17 | # @param sequence [Invoicexpress::Models::Sequence, String] The sequence or sequence ID
18 | # @return Invoicexpress::Models::Sequence The sequence
19 | # @raise Invoicexpress::Unauthorized When the client is unauthorized
20 | # @raise Invoicexpress::NotFound When the sequence doesn't exist
21 | def sequence(sequence, options={})
22 | params = { :klass => Invoicexpress::Models::Sequence }
23 |
24 | get("sequences/#{id_from_sequence(sequence)}.xml", params.merge(options))
25 | end
26 |
27 | # Creates a new sequence.
28 | #
29 | # @param sequence [Invoicexpress::Models::Sequence] The sequence to create
30 | # @return Invoicexpress::Models::Sequence The sequence
31 | # @raise Invoicexpress::Unauthorized When the client is unauthorized
32 | # @raise Invoicexpress::UnprocessableEntity When there are errors on the submission
33 | def create_sequence(sequence, options={})
34 | raise(ArgumentError, "sequence has the wrong type") unless sequence.is_a?(Invoicexpress::Models::Sequence)
35 |
36 | params = { :klass => Invoicexpress::Models::Sequence, :body => sequence }
37 | post("sequences.xml", params.merge(options))
38 | end
39 |
40 | # Updates a specific sequence.
41 | # Only sequences with no finalized invoices can be updated.
42 | #
43 | # @param sequence [Invoicexpress::Models::Sequence] The sequence to update
44 | # @raise Invoicexpress::Unauthorized When the client is unauthorized
45 | # @raise Invoicexpress::NotFound When the sequence doesn't exist
46 | # @raise Invoicexpress::UnprocessableEntity When there are errors on the submission
47 | def update_sequence(sequence, options={})
48 | raise(ArgumentError, "sequence has the wrong type") unless sequence.is_a?(Invoicexpress::Models::Sequence)
49 | if !sequence.id
50 | raise ArgumentError, "Sequence ID is required"
51 | end
52 | params = { :klass => Invoicexpress::Models::Sequence, :body => sequence }
53 | put("sequences/#{sequence.id}.xml", params.merge(options))
54 | end
55 |
56 | private
57 | def id_from_sequence(item)
58 | if item.is_a?(Invoicexpress::Models::Sequence)
59 | item.id
60 | elsif item.is_a?(String)
61 | item
62 | elsif item.is_a?(Integer)
63 | item.to_s
64 | else
65 | raise ArgumentError, "Cannot get sequence id from #{item}"
66 | end
67 | end
68 |
69 | end
70 | end
71 | end
72 |
--------------------------------------------------------------------------------
/doc/yard/Faraday.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 | Module: Faraday
8 |
9 | — Documentation by YARD 0.8.5
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
63 |
64 |
65 |
66 | Module: Faraday
67 |
68 |
69 | Private
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 | - Defined in:
82 | - lib/faraday/response/parse_xml.rb,
83 | lib/faraday/response/raise_invoicexpress_errors.rb
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 | This module is part of a private API.
93 | You should avoid using this module if possible, as it may be removed or be changed in the future.
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
119 |
120 |
121 |
--------------------------------------------------------------------------------
/lib/invoicexpress/client/taxes.rb:
--------------------------------------------------------------------------------
1 | module Invoicexpress
2 | class Client
3 | module Taxes
4 |
5 | # Returns all your taxes (lol)
6 | #
7 | # @return [Array] An array with all your taxes
8 | # @raise Invoicexpress::Unauthorized When the client is unauthorized
9 | def taxes(options = {})
10 | params = { :klass => Invoicexpress::Models::Tax }
11 |
12 | get("taxes.xml", params.merge(options))
13 | end
14 |
15 | # Returns a specific tax.
16 | #
17 | # @param tax [Invoicexpress::Models::Tax, String] The tax or tax ID
18 | # @return Invoicexpress::Models::Tax The tax
19 | # @raise Invoicexpress::Unauthorized When the client is unauthorized
20 | # @raise Invoicexpress::NotFound When the tax doesn't exist
21 | def tax(tax, options={})
22 | params = { :klass => Invoicexpress::Models::Tax }
23 |
24 | get("taxes/#{id_from_tax(tax)}.xml", params.merge(options))
25 | end
26 |
27 | # Creates a tax.
28 | #
29 | # @param tax [Invoicexpress::Models::Tax] The tax to create
30 | # @return Invoicexpress::Models::Tax The tax created
31 | # @raise Invoicexpress::Unauthorized When the client is unauthorized
32 | # @raise Invoicexpress::UnprocessableEntity When there are errors on the submission
33 | def create_tax(tax, options={})
34 | raise(ArgumentError, "tax has the wrong type") unless tax.is_a?(Invoicexpress::Models::Tax)
35 |
36 | params = { :klass => Invoicexpress::Models::Tax, :body => tax }
37 | post("taxes.xml", params.merge(options))
38 | end
39 |
40 | # Updates a tax.
41 | #
42 | # @param tax [Invoicexpress::Models::Tax] The tax to update
43 | # @raise Invoicexpress::Unauthorized When the client is unauthorized
44 | # @raise Invoicexpress::NotFound When the tax doesn't exist
45 | # @raise Invoicexpress::UnprocessableEntity When there are errors on the submission
46 | def update_tax(tax, options={})
47 | raise(ArgumentError, "tax has the wrong type") unless tax.is_a?(Invoicexpress::Models::Tax)
48 |
49 | if !tax.id
50 | raise ArgumentError, "Tax ID is required"
51 | end
52 | params = { :klass => Invoicexpress::Models::Tax, :body => tax }
53 | put("taxes/#{tax.id}.xml", params.merge(options))
54 | end
55 |
56 | # Deletes a tax.
57 | #
58 | # @param tax [Invoicexpress::Models::Tax, String] The tax or tax ID
59 | # @raise Invoicexpress::Unauthorized When the client is unauthorized
60 | # @raise Invoicexpress::NotFound When the tax doesn't exist
61 | def delete_tax(tax, options={})
62 | params = { :klass => Invoicexpress::Models::Tax }
63 |
64 | delete("taxes/#{id_from_tax(tax)}.xml", params.merge(options))
65 | end
66 |
67 | private
68 | def id_from_tax(item)
69 | if item.is_a?(Invoicexpress::Models::Tax)
70 | item.id
71 | elsif item.is_a?(String)
72 | item
73 | elsif item.is_a?(Integer)
74 | item.to_s
75 | else
76 | raise ArgumentError, "Cannot get tax id from #{item}"
77 | end
78 | end
79 |
80 | end
81 | end
82 | end
83 |
--------------------------------------------------------------------------------
/lib/invoicexpress/client/items.rb:
--------------------------------------------------------------------------------
1 | require 'invoicexpress/models'
2 |
3 | module Invoicexpress
4 | class Client
5 | module Items
6 |
7 | # Returns a list of all your items.
8 | #
9 | # @return [Array] An array with all your items
10 | # @raise Invoicexpress::Unauthorized When the client is unauthorized
11 | def items(options = {})
12 | params = { :klass => Invoicexpress::Models::Item }
13 |
14 | get("items.xml", params.merge(options))
15 | end
16 |
17 | # Returns a specific item.
18 | #
19 | # @param item [Invoicexpress::Models::Item, String] The item or item ID
20 | # @return [Invoicexpress::Models::Item] The item
21 | # @raise Invoicexpress::Unauthorized When the client is unauthorized
22 | # @raise Invoicexpress::NotFound When the item doesn't exist
23 | def item(item, options={})
24 | params = { :klass => Invoicexpress::Models::Item }
25 |
26 | get("items/#{id_from_item(item)}.xml", params.merge(options))
27 | end
28 |
29 | # Creates a new item.
30 | # Regarding item taxes, if the tax name is not found, no tax is applied to that item.
31 | #
32 | # @param item [Invoicexpress::Models::Item] The item to create
33 | # @return [Invoicexpress::Models::Item] The created item
34 | # @raise Invoicexpress::Unauthorized When the client is unauthorized
35 | # @raise Invoicexpress::UnprocessableEntity When there are errors on the submission
36 | def create_item(item, options={})
37 | raise(ArgumentError, "item has the wrong type") unless item.is_a?(Invoicexpress::Models::Item)
38 |
39 | params = { :klass => Invoicexpress::Models::Item, :body => item }
40 | post("items.xml", params.merge(options))
41 | end
42 |
43 | # Updates an item.
44 | #
45 | # @param item [Invoicexpress::Models::Item] The item to update
46 | # @return [Invoicexpress::Models::Item] The updated item
47 | # @raise Invoicexpress::Unauthorized When the client is unauthorized
48 | # @raise Invoicexpress::NotFound When the item doesn't exist
49 | # @raise Invoicexpress::UnprocessableEntity When there are errors on the submission
50 | def update_item(item, options={})
51 | raise(ArgumentError, "item has the wrong type") unless item.is_a?(Invoicexpress::Models::Item)
52 |
53 | params = { :klass => Invoicexpress::Models::Item, :body => item }
54 | put("items/#{item.id}.xml", params.merge(options))
55 | end
56 |
57 | # Deletes an item.
58 | #
59 | # @param item [Invoicexpress::Models::Item, String] The item or item id
60 | # @raise Invoicexpress::Unauthorized When the client is unauthorized
61 | # @raise Invoicexpress::NotFound When the item doesn't exist
62 | def delete_item(item, options={})
63 | params = { :klass => Invoicexpress::Models::Item }
64 | delete("items/#{id_from_item(item)}.xml", params.merge(options))
65 | end
66 |
67 | private
68 | def id_from_item(item)
69 | if item.is_a?(Invoicexpress::Models::Item)
70 | item.id
71 | elsif item.is_a?(String)
72 | item
73 | elsif item.is_a?(Integer)
74 | item.to_s
75 | else
76 | raise ArgumentError, "Cannot get item id from #{item}"
77 | end
78 | end
79 |
80 | end
81 | end
82 | end
83 |
--------------------------------------------------------------------------------
/spec/invoicexpress/client/clients_spec.rb:
--------------------------------------------------------------------------------
1 | require 'helper'
2 |
3 | describe Invoicexpress::Client::Clients do
4 |
5 | before do
6 | @client = Invoicexpress::Client.new(:screen_name => "thinkorangeteste")
7 | end
8 |
9 | describe ".clients" do
10 | it "returns all the clients" do
11 | stub_get("/clients.xml?per_page=30&page=1").
12 | to_return(xml_response("clients.list.xml"))
13 |
14 | list = @client.clients
15 | list.count.should == 1
16 | list.first.name.should == "Ruben Fonseca"
17 | list.first.email.should == "fonseka@gmail.com"
18 | end
19 | end
20 |
21 | describe ".create_client" do
22 | it "creates a new client" do
23 | stub_post("/clients.xml").
24 | to_return(xml_response("clients.create.xml"))
25 |
26 | model_client = Invoicexpress::Models::Client.new({
27 | :name => "Ruben Fonseca",
28 | :email => "fonseka@gmail.com"
29 | })
30 |
31 | new_client = @client.create_client(model_client)
32 | new_client.name.should == "Ruben Fonseca"
33 | new_client.email.should == "fonseka@gmail.com"
34 | end
35 |
36 | it "raises if no client is passed" do
37 | expect {
38 | @client.create_client(nil)
39 | }.to raise_error(ArgumentError)
40 | end
41 |
42 | it "raises if the client has no name" do
43 | expect {
44 | @client.create_client(Invoicexpress::Models::Client.new)
45 | }.to raise_error(ArgumentError)
46 | end
47 | end
48 |
49 | describe ".update_client" do
50 | it "updates the client" do
51 | stub_put("/clients/123.xml").
52 | to_return(xml_response("clients.update.xml"))
53 |
54 | model = Invoicexpress::Models::Client.new(:id => 123)
55 |
56 | expect { @client.update_client(model) }.to_not raise_error
57 | end
58 |
59 | it "raises if no client is passed" do
60 | expect {
61 | @client.update_client(nil)
62 | }.to raise_error(ArgumentError)
63 | end
64 |
65 | it "raises if the client to update has no id" do
66 | expect {
67 | @client.update_client(Invoicexpress::Models::Client.new)
68 | }.to raise_error(ArgumentError)
69 | end
70 | end
71 |
72 | describe ".client" do
73 | it "gets a client" do
74 | stub_get("/clients/1.xml").
75 | to_return(xml_response("clients.get.xml"))
76 |
77 | c = @client.client(1)
78 | c.name.should == "Bruce Norris"
79 | c.code.should == 1337
80 | end
81 | end
82 |
83 | describe ".client_invoices" do
84 | it "gets the client's invoices" do
85 | stub_post("/clients/1/invoices.xml").
86 | to_return(xml_response("clients.invoices.xml"))
87 |
88 | invoices = @client.client_invoices(1)
89 | invoices.results.entries.should == 0
90 | invoices.results.total_entries == 0
91 | end
92 |
93 | it "gets the client's invoices with filters" do
94 | filter = Invoicexpress::Models::Filter.new({
95 | :status => [:draft, :final],
96 | :by_type => ["Receipt"],
97 | :archived => [:non_archived]
98 | })
99 |
100 | stub_post("/clients/1/invoices.xml").
101 | to_return(xml_response("clients.invoices.xml"))
102 |
103 | invoices = @client.client_invoices(1, filter)
104 | invoices.results.entries.should == 0
105 | end
106 | end
107 |
108 | end
109 |
--------------------------------------------------------------------------------
/doc/yard/Invoicexpress/Models/Errors.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 | Class: Invoicexpress::Models::Errors
8 |
9 | — Documentation by YARD 0.8.5
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
63 |
64 |
65 |
66 | Class: Invoicexpress::Models::Errors
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | - Inherits:
75 | -
76 | Object
77 |
78 |
79 | - Object
80 |
81 | - Invoicexpress::Models::Errors
82 |
83 |
84 | show all
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 | - Includes:
94 | - HappyMapper
95 |
96 |
97 |
98 |
99 |
100 | - Defined in:
101 | - lib/invoicexpress/error.rb
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
123 |
124 |
125 |
--------------------------------------------------------------------------------
/doc/yard/Invoicexpress/Models/Value.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 | Class: Invoicexpress::Models::Value
8 |
9 | — Documentation by YARD 0.8.5
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
63 |
64 |
65 |
66 | Class: Invoicexpress::Models::Value
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | - Inherits:
75 | -
76 | Object
77 |
78 |
79 | - Object
80 |
81 | - Invoicexpress::Models::Value
82 |
83 |
84 | show all
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 | - Includes:
94 | - HappyMapper
95 |
96 |
97 |
98 |
99 |
100 | - Defined in:
101 | - lib/invoicexpress/models/chart.rb
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
123 |
124 |
125 |
--------------------------------------------------------------------------------
/doc/yard/Invoicexpress/Models/InvoiceResult.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 | Class: Invoicexpress::Models::InvoiceResult
8 |
9 | — Documentation by YARD 0.8.5
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
63 |
64 |
65 |
66 | Class: Invoicexpress::Models::InvoiceResult
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | - Inherits:
75 | -
76 | Object
77 |
78 |
79 | - Object
80 |
81 | - Invoicexpress::Models::InvoiceResult
82 |
83 |
84 | show all
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 | - Includes:
94 | - HappyMapper
95 |
96 |
97 |
98 |
99 |
100 | - Defined in:
101 | - lib/invoicexpress/models/invoice.rb
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
123 |
124 |
125 |
--------------------------------------------------------------------------------
/spec/invoicexpress/client/invoices_spec.rb:
--------------------------------------------------------------------------------
1 | require 'helper'
2 |
3 | describe Invoicexpress::Client::Invoices do
4 | before do
5 | @client = Invoicexpress::Client.new(:screen_name => "thinkorangeteste")
6 | end
7 |
8 | describe ".invoices" do
9 | it "Returns all the invoice" do
10 | stub_get("/invoices.xml?page=1").
11 | to_return(xml_response("invoices.list.xml"))
12 |
13 | items = @client.invoices
14 | items.invoices.count.should == 10
15 | items.current_page==1
16 | end
17 | end
18 |
19 | describe ".create_invoice" do
20 | it "creates a new invoice" do
21 | stub_post("/invoices.xml").
22 | to_return(xml_response("invoices.create.xml"))
23 |
24 |
25 | object = Invoicexpress::Models::Invoice.new(
26 | :date => Date.new(2013, 6, 18),
27 | :due_date => Date.new(2013, 6, 18),
28 | :tax_exemption => "M01",
29 | :client => Invoicexpress::Models::Client.new(
30 | :name => "Ruben Fonseca"
31 | ),
32 | :items => [
33 | Invoicexpress::Models::Item.new(
34 | :name => "Item 1",
35 | :unit_price => 30,
36 | :quantity => 1,
37 | :unit => "unit",
38 | )
39 | ]
40 | )
41 |
42 | item = @client.create_invoice(object)
43 | item.id.should == 1503698
44 | item.status == "draft"
45 | end
46 | end
47 |
48 | describe ".invoice" do
49 | it "gets a invoice" do
50 | stub_get("/invoices/1503698.xml").
51 | to_return(xml_response("invoices.get.xml"))
52 |
53 | item = @client.invoice(1503698)
54 | item.status.should == "draft"
55 | item.client.id.should == 501854
56 | end
57 | end
58 |
59 | describe ".update_invoice" do
60 | it "updates the invoice" do
61 | stub_put("/invoices/1503698.xml").
62 | to_return(xml_response("ok.xml"))
63 |
64 | model = Invoicexpress::Models::Invoice.new(:id => 1503698)
65 | expect { @client.update_invoice(model) }.to_not raise_error
66 | end
67 |
68 | it "raises if no invoice is passed" do
69 | expect {
70 | @client.update_invoice(nil)
71 | }.to raise_error(ArgumentError)
72 | end
73 |
74 | it "raises if the simplified invoice to update has no id" do
75 | stub_put("/invoices/.xml").
76 | to_return(xml_response("ok.xml"))
77 | expect {
78 | @client.update_invoice(Invoicexpress::Models::SimplifiedInvoice.new)
79 | }.to raise_error(ArgumentError)
80 | end
81 | end
82 |
83 | describe ".update_invoice_state" do
84 | it "updates the state" do
85 | stub_put("/invoices/1503698/change-state.xml").
86 | to_return(xml_response("invoices.update_state.xml"))
87 |
88 | state = Invoicexpress::Models::InvoiceState.new(
89 | :state => "finalized"
90 | )
91 | expect { @client.update_invoice_state(1503698, state) }.to_not raise_error
92 | end
93 | end
94 |
95 | describe ".email_invoice" do
96 | it "sends the invoice through email" do
97 | stub_put("/invoice/1503698/email-invoice.xml").
98 | to_return(xml_response("ok.xml"))
99 | message = Invoicexpress::Models::Message.new(
100 | :subject => "Hello world",
101 | :body => "Here is the invoice.",
102 | :client => Invoicexpress::Models::Client.new(
103 | :name => "Pedro Sousa",
104 | :email=> 'info@thinkorange.pt'
105 | )
106 | )
107 | expect { @client.email_invoice(1503698, message) }.to_not raise_error
108 | end
109 | end
110 | end
111 |
--------------------------------------------------------------------------------
/spec/invoicexpress/client/credit_notes_spec.rb:
--------------------------------------------------------------------------------
1 | require 'helper'
2 |
3 | describe Invoicexpress::Client::CreditNotes do
4 | before do
5 | @client = Invoicexpress::Client.new(:screen_name => "thinkorangeteste")
6 | end
7 |
8 | describe ".credit_notes" do
9 | it "Returns all the credit notes" do
10 | stub_get("/credit_notes.xml?page=1").
11 | to_return(xml_response("credit_notes.list.xml"))
12 |
13 | credit_notes = @client.credit_notes
14 | credit_notes.count.should == 2
15 | credit_notes.first.id == 1415679
16 | end
17 | end
18 |
19 | describe ".create_credit_note" do
20 | it "creates a new credit note" do
21 | stub_post("/credit_notes.xml").
22 | to_return(xml_response("credit_notes.create.xml"))
23 |
24 |
25 | cnote = Invoicexpress::Models::CreditNote.new(
26 | :date => Date.new(2013, 5, 1),
27 | :due_date => Date.new(2013, 6, 1),
28 | :tax_exemption => "M01",
29 | :client => Invoicexpress::Models::Client.new(
30 | :name => "Pedro Sousa"
31 | ),
32 | :items => [
33 | Invoicexpress::Models::Item.new(
34 | :name => "Item 1",
35 | :unit_price => 60,
36 | :quantity => 2,
37 | :unit => "unit",
38 | ),
39 | Invoicexpress::Models::Item.new(
40 | :name => "Item 2",
41 | :unit_price => 50,
42 | :quantity => 1,
43 | :unit => "unit",
44 | )
45 | ]
46 | )
47 |
48 | cnote = @client.create_credit_note(cnote)
49 | cnote.id.should == 1423940
50 | cnote.status == "draft"
51 | end
52 | end
53 |
54 | describe ".update_credit_note" do
55 | it "updates the credit note" do
56 | stub_put("/credit_notes/1423940.xml").
57 | to_return(xml_response("ok.xml"))
58 |
59 | model = Invoicexpress::Models::CreditNote.new(:id => 1423940)
60 | expect { @client.update_credit_note(model) }.to_not raise_error
61 | end
62 | it "raises if no credit note is passed" do
63 | expect {
64 | @client.update_credit_note(nil)
65 | }.to raise_error(ArgumentError)
66 | end
67 | it "raises if the credit_note to update has no id" do
68 | stub_put("/credit_notes/.xml").
69 | to_return(xml_response("ok.xml"))
70 | expect {
71 | @client.update_credit_note(Invoicexpress::Models::CreditNote.new)
72 | }.to raise_error(ArgumentError)
73 | end
74 | end
75 |
76 | describe ".update_credit_note_state" do
77 | it "updates the state" do
78 | stub_put("/credit_notes/1423940/change-state.xml").
79 | to_return(xml_response("credit_notes.update_state.xml"))
80 |
81 | state = Invoicexpress::Models::InvoiceState.new(
82 | :state => "finalized"
83 | )
84 | expect { cnote = @client.update_credit_note_state(1423940, state) }.to_not raise_error
85 | end
86 | end
87 |
88 | describe ".credit_note_mail" do
89 | it "sends the credit note through email" do
90 | stub_put("/credit_notes/1423940/email-document.xml").
91 | to_return(xml_response("credit_notes.email_document.xml"))
92 |
93 | message = Invoicexpress::Models::Message.new(
94 | :subject => "Hello world",
95 | :body => "Here is the invoice.",
96 | :client => Invoicexpress::Models::Client.new(
97 | :name => "Pedro Sousa",
98 | :email=> 'psousa@thinkorange.pt'
99 | )
100 | )
101 | expect { cnote = @client.credit_note_mail(1423940, message) }.to_not raise_error
102 | end
103 | end
104 | end
105 |
--------------------------------------------------------------------------------
/spec/fixtures/credit_notes.list.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 1
5 | 2
6 | 2
7 |
8 |
9 | 1415679
10 | final
11 | false
12 | CreditNote
13 | 1/2013
14 | 01/02/2013
15 | 01/02/2013
16 |
17 | Artigo 16º nº 6 do CIVA.
18 |
19 |
20 | 550611
21 | Pedro Sousa
22 | psousa@thinkorange.pt
23 | Rua Luisa de Camões 18
24 | 1231-123
25 | Portugal
26 | 210533382
27 |
28 | Euro
29 |
30 | -
31 | Item 1
32 |
33 | 30.0
34 | unit
35 | 2.0
36 |
37 |
38 | 0.0
39 |
40 | 0.0
41 |
42 | -
43 | Item 2
44 |
45 | 50.0
46 | unit
47 | 3.0
48 |
49 |
50 | 0.0
51 |
52 | 0.0
53 |
54 |
55 | 210.0
56 | 0.0
57 | 210.0
58 | 0.0
59 | 210.0
60 |
61 |
62 | 1415679
63 | final
64 | false
65 | CreditNote
66 | 1/2013
67 | 01/02/2013
68 | 01/02/2013
69 |
70 | Artigo 16º nº 6 do CIVA.
71 |
72 |
73 | 550611
74 | Pedro Sousa
75 | psousa@thinkorange.pt
76 | Rua Luisa de Camões 18
77 | 1231-123
78 | Portugal
79 | 210533382
80 |
81 | Euro
82 |
83 | -
84 | Item 1
85 |
86 | 30.0
87 | unit
88 | 2.0
89 |
90 |
91 | 0.0
92 |
93 | 0.0
94 |
95 | -
96 | Item 2
97 |
98 | 50.0
99 | unit
100 | 3.0
101 |
102 |
103 | 0.0
104 |
105 | 0.0
106 |
107 |
108 | 210.0
109 | 0.0
110 | 210.0
111 | 0.0
112 | 210.0
113 |
114 |
115 |
--------------------------------------------------------------------------------
/spec/invoicexpress/client/schedules_spec.rb:
--------------------------------------------------------------------------------
1 | require 'helper'
2 |
3 | describe Invoicexpress::Client::Schedules do
4 | before do
5 | @client = Invoicexpress::Client.new(:screen_name => "thinkorangeteste")
6 | end
7 |
8 | describe ".schedules" do
9 | it "Returns all the schedules" do
10 | stub_get("/schedules.xml").
11 | to_return(xml_response("schedules.list.xml"))
12 |
13 | list = @client.schedules
14 | list.count.should == 1
15 | list.first.client.id==439232
16 | list.first.items.size==1
17 | end
18 | end
19 |
20 | describe ".schedule" do
21 | it "gets a schedule" do
22 | stub_get("/schedules/4462.xml").
23 | to_return(xml_response("schedules.get.xml"))
24 |
25 | c = @client.schedule(4462)
26 | c.id.should == 4462
27 | c.sum.should == 360.0
28 | end
29 | end
30 |
31 | describe ".update_schedule" do
32 | it "updates the schedule" do
33 | stub_put("/schedules/4462.xml").
34 | to_return(xml_response("ok.xml"))
35 |
36 | model = Invoicexpress::Models::Schedule.new(
37 | :id=>4462,
38 | :start_date => Date.new(2013, 6, 16),
39 | :end_date => Date.new(2013, 8, 18),
40 | :create_back => "Yes",
41 | :schedule_type => "Monthly",
42 | :interval => 2,
43 | :send_to_client => "No",
44 | :description=> "created from API.",
45 | :invoice_template=> Invoicexpress::Models::InvoiceTemplate.new(
46 | :due_days=>1,
47 | :client => Invoicexpress::Models::Client.new(
48 | :name => "Chuck Norris",
49 | :email=>'chuck@thinkorange.pt'
50 | ),
51 | :items => [
52 | Invoicexpress::Models::Item.new(
53 | :name => "Item 1",
54 | :unit_price => 30,
55 | :quantity => 2,
56 | :unit => "unit",
57 | :tax=>Invoicexpress::Models::Tax.new(
58 | :name => "IVA23",
59 | )
60 | ),
61 | Invoicexpress::Models::Item.new(
62 | :name => "Item 2",
63 | :unit_price => 60,
64 | :quantity => 5,
65 | :unit => "unit",
66 | :tax=>Invoicexpress::Models::Tax.new(
67 | :name => "IVA23",
68 | )
69 | )
70 | ]
71 | )
72 | )
73 |
74 | expect { @client.update_schedule(model) }.to_not raise_error
75 | end
76 |
77 | it "raises if no schedule is passed" do
78 | expect {
79 | @client.update_schedule(nil)
80 | }.to raise_error(ArgumentError)
81 | end
82 |
83 | it "raises if the schedule to update has no id" do
84 | stub_put("/schedules/.xml").
85 | to_return(xml_response("ok.xml"))
86 | expect {
87 | @client.update_schedule(Invoicexpress::Models::Schedule.new)
88 | }.to raise_error(ArgumentError)
89 | end
90 | end
91 |
92 | describe ".activate_schedule" do
93 | it "activates the schedule" do
94 | stub_put("/schedules/4462/activate").
95 | to_return(xml_response("ok.xml"))
96 | model = Invoicexpress::Models::Schedule.new(:id=>4462)
97 | expect { item = @client.activate_schedule(model) }.to_not raise_error
98 | end
99 | end
100 |
101 | describe ".deactivate_schedule" do
102 | it "deactivates the schedule" do
103 | stub_put("/schedules/4462/deactivate").
104 | to_return(xml_response("ok.xml"))
105 | model = Invoicexpress::Models::Schedule.new(:id=>4462)
106 | expect { item = @client.deactivate_schedule(model) }.to_not raise_error
107 | end
108 | end
109 |
110 | end
111 |
112 |
--------------------------------------------------------------------------------
/spec/fixtures/simplified_invoices.list.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 1
5 | 2
6 | 2
7 |
8 |
9 | 1425061
10 | settled
11 | false
12 | SimplifiedInvoice
13 | 1/2013
14 | 01/05/2013
15 |
16 | Artigo 16º nº 6 do CIVA.
17 |
18 | http://www.invoicexpress.net/documents/9c21e2aa2fd5a9f999673bc993407a562177fecb
19 |
20 | 550611
21 | Pedro Sousa
22 | psousa@thinkorange.pt
23 | Rua Luisa de Camões 18
24 | 1231-123
25 | Portugal
26 | 210533382
27 |
28 | Euro
29 |
30 | -
31 | Item 1
32 |
33 | 60.0
34 | unit
35 | 2.0
36 |
37 |
38 | 0.0
39 |
40 | 0.0
41 |
42 | -
43 | Item 2
44 |
45 | 50.0
46 | unit
47 | 1.0
48 |
49 |
50 | 0.0
51 |
52 | 0.0
53 |
54 |
55 | 170.0
56 | 0.0
57 | 170.0
58 | 0.0
59 | 170.0
60 |
61 |
62 | 1425061
63 | settled
64 | false
65 | SimplifiedInvoice
66 | 1/2013
67 | 01/05/2013
68 |
69 | Artigo 16º nº 6 do CIVA.
70 |
71 | http://www.invoicexpress.net/documents/9c21e2aa2fd5a9f999673bc993407a562177fecb
72 |
73 | 550611
74 | Pedro Sousa
75 | psousa@thinkorange.pt
76 | Rua Luisa de Camões 18
77 | 1231-123
78 | Portugal
79 | 210533382
80 |
81 | Euro
82 |
83 | -
84 | Item 1
85 |
86 | 60.0
87 | unit
88 | 2.0
89 |
90 |
91 | 0.0
92 |
93 | 0.0
94 |
95 | -
96 | Item 2
97 |
98 | 50.0
99 | unit
100 | 1.0
101 |
102 |
103 | 0.0
104 |
105 | 0.0
106 |
107 |
108 | 170.0
109 | 0.0
110 | 170.0
111 | 0.0
112 | 170.0
113 |
114 |
115 |
--------------------------------------------------------------------------------
/spec/invoicexpress/client/purchase_orders_spec.rb:
--------------------------------------------------------------------------------
1 | require 'helper'
2 |
3 | describe Invoicexpress::Client::PurchaseOrders do
4 | before do
5 | @client = Invoicexpress::Client.new(:screen_name => "thinkorangeteste")
6 | end
7 |
8 | describe ".purchase_orders" do
9 | it "Returns all the purchase orders" do
10 | stub_get("/purchase_orders.xml?page=1").
11 | to_return(xml_response("po.list.xml"))
12 |
13 | items = @client.purchase_orders
14 | items.count.should == 1
15 | items.first.id == 1430276
16 | end
17 | end
18 |
19 | describe ".create_purchase_order" do
20 | it "creates a new purchase order" do
21 | stub_post("/purchase_orders.xml").
22 | to_return(xml_response("po.create.xml"))
23 |
24 | object = Invoicexpress::Models::PurchaseOrder.new(
25 | :date => Date.new(2013, 5, 30),
26 | :due_date => Date.new(2013, 8, 8),
27 | :loaded_at => Date.new(2013, 5, 30),
28 | :delivery_site=>'LX Factory',
29 | :supplier => Invoicexpress::Models::Supplier.new(
30 | :name => "Pedro Sousa",
31 | ),
32 | :items => [
33 | Invoicexpress::Models::Item.new(
34 | :name => "Item 1",
35 | :unit_price => 60,
36 | :quantity => 2,
37 | :unit => "unit",
38 | :tax=> Invoicexpress::Models::Tax.new(
39 | :name=>'IVA23'
40 | )
41 | )
42 | ]
43 | )
44 |
45 | item = @client.create_purchase_order(object)
46 | item.id.should == 1430276
47 | item.delivery_site.should == "LX Factory"
48 | end
49 | end
50 |
51 | describe ".purchase_order" do
52 | it "gets a purchase order" do
53 | stub_get("/purchase_orders/1430276.xml").
54 | to_return(xml_response("po.get.xml"))
55 |
56 | item = @client.purchase_order(1430276)
57 | item.status.should == "draft"
58 | item.delivery_site.should == "LX Factory"
59 | end
60 | end
61 |
62 | describe ".update_purchase_order" do
63 | it "updates the purchase order" do
64 | stub_put("/purchase_orders/1430276.xml").
65 | to_return(xml_response("clients.update.xml"))
66 |
67 | model = Invoicexpress::Models::PurchaseOrder.new(:id => 1430276)
68 | expect { @client.update_purchase_order(model) }.to_not raise_error
69 | end
70 |
71 | it "raises if no purchase is passed" do
72 | expect {
73 | @client.update_purchase_order(nil)
74 | }.to raise_error(ArgumentError)
75 | end
76 |
77 | it "raises if the purchase order update has no id" do
78 | stub_put("/purchase_orders/.xml").
79 | to_return(xml_response("ok.xml"))
80 | expect {
81 | @client.update_purchase_order(Invoicexpress::Models::PurchaseOrder.new)
82 | }.to raise_error(ArgumentError)
83 | end
84 | end
85 |
86 |
87 | describe ".update_purchase_order_state" do
88 | it "updates the state" do
89 | stub_put("/purchase_orders/1430338/change-state.xml").
90 | to_return(xml_response("po.update_state.xml"))
91 |
92 | state = Invoicexpress::Models::InvoiceState.new(
93 | :state => "finalized"
94 | )
95 |
96 | expect { item = @client.update_purchase_order_state(1430338, state) }.to_not raise_error
97 | end
98 | end
99 |
100 | describe ".simplified_invoice_mail" do
101 | it "sends the invoice through email" do
102 | stub_put("/purchase_orders/1430338/email-document.xml").
103 | to_return(xml_response("po.email_document.xml"))
104 |
105 | message = Invoicexpress::Models::Message.new(
106 | :subject => "Hello world",
107 | :body => "Here is the invoice.",
108 | :client => Invoicexpress::Models::Client.new(
109 | :name => "Pedro Sousa",
110 | :email=> 'psousa@thinkorange.pt'
111 | )
112 | )
113 | expect {item = @client.purchase_order_mail(1430338, message) }.to_not raise_error
114 | end
115 | end
116 | end
117 |
--------------------------------------------------------------------------------
/spec/invoicexpress/client/simplified_invoices_spec.rb:
--------------------------------------------------------------------------------
1 | require 'helper'
2 |
3 | describe Invoicexpress::Client::SimplifiedInvoices do
4 | before do
5 | @client = Invoicexpress::Client.new(:screen_name => "thinkorangeteste")
6 | end
7 |
8 | describe ".simplified_invoices" do
9 | it "Returns all the simplified invoices" do
10 | stub_get("/simplified_invoices.xml?page=1").
11 | to_return(xml_response("simplified_invoices.list.xml"))
12 |
13 | items = @client.simplified_invoices
14 | items.count.should == 2
15 | items.first.id == 1425061
16 | end
17 | end
18 |
19 | describe ".create_simplified_invoice" do
20 | it "creates a new simplified invoice" do
21 | stub_post("/simplified_invoices.xml").
22 | to_return(xml_response("simplified_invoices.create.xml"))
23 |
24 |
25 | object = Invoicexpress::Models::SimplifiedInvoice.new(
26 | :date => Date.new(2013, 5, 1),
27 | :due_date => Date.new(2013, 6, 1),
28 | :tax_exemption => "M01",
29 | :client => Invoicexpress::Models::Client.new(
30 | :name => "Pedro Sousa"
31 | ),
32 | :items => [
33 | Invoicexpress::Models::Item.new(
34 | :name => "Item 1",
35 | :unit_price => 60,
36 | :quantity => 2,
37 | :unit => "unit",
38 | ),
39 | Invoicexpress::Models::Item.new(
40 | :name => "Item 2",
41 | :unit_price => 50,
42 | :quantity => 1,
43 | :unit => "unit",
44 | )
45 | ]
46 | )
47 |
48 | item = @client.create_simplified_invoice(object)
49 | item.id.should == 1425061
50 | item.status == "draft"
51 | end
52 | end
53 |
54 | describe ".simplified_invoice" do
55 | it "gets a simplified invoice" do
56 | stub_get("/simplified_invoices/1425061.xml").
57 | to_return(xml_response("simplified_invoices.get.xml"))
58 |
59 | item = @client.simplified_invoice(1425061)
60 | item.status.should == "settled"
61 | item.sequence_number.should == "1/2013"
62 | end
63 | end
64 |
65 | describe ".update_simplified_invoice" do
66 | it "updates the simplified invoice" do
67 | stub_put("/simplified_invoices/1425061.xml").
68 | to_return(xml_response("clients.update.xml"))
69 |
70 | model = Invoicexpress::Models::SimplifiedInvoice.new(:id => 1425061)
71 | expect { @client.update_simplified_invoice(model) }.to_not raise_error
72 | end
73 | it "raises if no simplified invoice is passed" do
74 | expect {
75 | @client.update_simplified_invoice(nil)
76 | }.to raise_error(ArgumentError)
77 | end
78 |
79 | it "raises if the simplified invoice to update has no id" do
80 | stub_put("/schedules/.xml").
81 | to_return(xml_response("ok.xml"))
82 | expect {
83 | @client.update_simplified_invoice(Invoicexpress::Models::SimplifiedInvoice.new)
84 | }.to raise_error(ArgumentError)
85 | end
86 | end
87 |
88 | describe ".update_simplified_invoice_state" do
89 | it "updates the state" do
90 | stub_put("/simplified_invoices/1425061/change-state.xml").
91 | to_return(xml_response("simplified_invoices.update_state.xml"))
92 |
93 | state = Invoicexpress::Models::InvoiceState.new(
94 | :state => "finalized"
95 | )
96 | expect { item = @client.update_simplified_invoice_state(1425061, state) }.to_not raise_error
97 | end
98 | end
99 |
100 | describe ".simplified_invoice_mail" do
101 | it "sends the invoice through email" do
102 | stub_put("/simplified_invoices/1425061/email-document.xml").
103 | to_return(xml_response("simplified_invoices.email_document.xml"))
104 |
105 | message = Invoicexpress::Models::Message.new(
106 | :subject => "Hello world",
107 | :body => "Here is the invoice.",
108 | :client => Invoicexpress::Models::Client.new(
109 | :name => "Pedro Sousa",
110 | :email=> 'psousa@thinkorange.pt'
111 | )
112 | )
113 | expect {item = @client.simplified_invoice_mail(1425061, message) }.to_not raise_error
114 | end
115 | end
116 | end
117 |
--------------------------------------------------------------------------------
/doc/yard/Invoicexpress/Models/Tax.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 | Class: Invoicexpress::Models::Tax
8 |
9 | — Documentation by YARD 0.8.5
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
63 |
64 |
65 |
66 | Class: Invoicexpress::Models::Tax
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | - Inherits:
75 | -
76 | BaseModel
77 |
78 |
79 | - Object
80 |
81 | - BaseModel
82 |
83 | - Invoicexpress::Models::Tax
84 |
85 |
86 | show all
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 | - Includes:
96 | - HappyMapper
97 |
98 |
99 |
100 |
101 |
102 | - Defined in:
103 | - lib/invoicexpress/models/invoice.rb
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
Method Summary
124 |
125 |
Methods inherited from BaseModel
126 |
#initialize
127 |
133 |
134 |
135 |
136 |
137 |
142 |
143 |
144 |
--------------------------------------------------------------------------------
/doc/yard/Invoicexpress/Models/Item.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 | Class: Invoicexpress::Models::Item
8 |
9 | — Documentation by YARD 0.8.5
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
63 |
64 |
65 |
66 | Class: Invoicexpress::Models::Item
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | - Inherits:
75 | -
76 | BaseModel
77 |
78 |
79 | - Object
80 |
81 | - BaseModel
82 |
83 | - Invoicexpress::Models::Item
84 |
85 |
86 | show all
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 | - Includes:
96 | - HappyMapper
97 |
98 |
99 |
100 |
101 |
102 | - Defined in:
103 | - lib/invoicexpress/models/invoice.rb
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
Method Summary
124 |
125 |
Methods inherited from BaseModel
126 |
#initialize
127 |
133 |
134 |
135 |
136 |
137 |
142 |
143 |
144 |
--------------------------------------------------------------------------------
/doc/yard/Invoicexpress/Models/Chart.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 | Class: Invoicexpress::Models::Chart
8 |
9 | — Documentation by YARD 0.8.5
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
63 |
64 |
65 |
66 | Class: Invoicexpress::Models::Chart
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | - Inherits:
75 | -
76 | BaseModel
77 |
78 |
79 | - Object
80 |
81 | - BaseModel
82 |
83 | - Invoicexpress::Models::Chart
84 |
85 |
86 | show all
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 | - Includes:
96 | - HappyMapper
97 |
98 |
99 |
100 |
101 |
102 | - Defined in:
103 | - lib/invoicexpress/models/chart.rb
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
Method Summary
124 |
125 |
Methods inherited from BaseModel
126 |
#initialize
127 |
133 |
134 |
135 |
136 |
137 |
142 |
143 |
144 |
--------------------------------------------------------------------------------
/doc/yard/Invoicexpress/Models/Graph.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 | Class: Invoicexpress::Models::Graph
8 |
9 | — Documentation by YARD 0.8.5
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
63 |
64 |
65 |
66 | Class: Invoicexpress::Models::Graph
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | - Inherits:
75 | -
76 | BaseModel
77 |
78 |
79 | - Object
80 |
81 | - BaseModel
82 |
83 | - Invoicexpress::Models::Graph
84 |
85 |
86 | show all
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 | - Includes:
96 | - HappyMapper
97 |
98 |
99 |
100 |
101 |
102 | - Defined in:
103 | - lib/invoicexpress/models/chart.rb
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
Method Summary
124 |
125 |
Methods inherited from BaseModel
126 |
#initialize
127 |
133 |
134 |
135 |
136 |
137 |
142 |
143 |
144 |
--------------------------------------------------------------------------------
/doc/yard/Invoicexpress/Models/Items.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 | Class: Invoicexpress::Models::Items
8 |
9 | — Documentation by YARD 0.8.5
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
63 |
64 |
65 |
66 | Class: Invoicexpress::Models::Items
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | - Inherits:
75 | -
76 | BaseModel
77 |
78 |
79 | - Object
80 |
81 | - BaseModel
82 |
83 | - Invoicexpress::Models::Items
84 |
85 |
86 | show all
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 | - Includes:
96 | - HappyMapper
97 |
98 |
99 |
100 |
101 |
102 | - Defined in:
103 | - lib/invoicexpress/models/invoice.rb
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
Method Summary
124 |
125 |
Methods inherited from BaseModel
126 |
#initialize
127 |
133 |
134 |
135 |
136 |
137 |
142 |
143 |
144 |
--------------------------------------------------------------------------------
/doc/yard/Invoicexpress/Models/Client.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 | Class: Invoicexpress::Models::Client
8 |
9 | — Documentation by YARD 0.8.5
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
63 |
64 |
65 |
66 | Class: Invoicexpress::Models::Client
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | - Inherits:
75 | -
76 | BaseModel
77 |
78 |
79 | - Object
80 |
81 | - BaseModel
82 |
83 | - Invoicexpress::Models::Client
84 |
85 |
86 | show all
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 | - Includes:
96 | - HappyMapper
97 |
98 |
99 |
100 |
101 |
102 | - Defined in:
103 | - lib/invoicexpress/models/client.rb
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
Method Summary
124 |
125 |
Methods inherited from BaseModel
126 |
#initialize
127 |
133 |
134 |
135 |
136 |
137 |
142 |
143 |
144 |
--------------------------------------------------------------------------------
/doc/yard/Invoicexpress/Models/Graphs.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 | Class: Invoicexpress::Models::Graphs
8 |
9 | — Documentation by YARD 0.8.5
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
63 |
64 |
65 |
66 | Class: Invoicexpress::Models::Graphs
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | - Inherits:
75 | -
76 | BaseModel
77 |
78 |
79 | - Object
80 |
81 | - BaseModel
82 |
83 | - Invoicexpress::Models::Graphs
84 |
85 |
86 | show all
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 | - Includes:
96 | - HappyMapper
97 |
98 |
99 |
100 |
101 |
102 | - Defined in:
103 | - lib/invoicexpress/models/chart.rb
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
Method Summary
124 |
125 |
Methods inherited from BaseModel
126 |
#initialize
127 |
133 |
134 |
135 |
136 |
137 |
142 |
143 |
144 |
--------------------------------------------------------------------------------
/doc/yard/Invoicexpress/Models/Series.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 | Class: Invoicexpress::Models::Series
8 |
9 | — Documentation by YARD 0.8.5
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
63 |
64 |
65 |
66 | Class: Invoicexpress::Models::Series
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | - Inherits:
75 | -
76 | BaseModel
77 |
78 |
79 | - Object
80 |
81 | - BaseModel
82 |
83 | - Invoicexpress::Models::Series
84 |
85 |
86 | show all
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 | - Includes:
96 | - HappyMapper
97 |
98 |
99 |
100 |
101 |
102 | - Defined in:
103 | - lib/invoicexpress/models/chart.rb
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
Method Summary
124 |
125 |
Methods inherited from BaseModel
126 |
#initialize
127 |
133 |
134 |
135 |
136 |
137 |
142 |
143 |
144 |
--------------------------------------------------------------------------------
/doc/yard/Invoicexpress/Models/Account.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 | Class: Invoicexpress::Models::Account
8 |
9 | — Documentation by YARD 0.8.5
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
63 |
64 |
65 |
66 | Class: Invoicexpress::Models::Account
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | - Inherits:
75 | -
76 | BaseModel
77 |
78 |
79 | - Object
80 |
81 | - BaseModel
82 |
83 | - Invoicexpress::Models::Account
84 |
85 |
86 | show all
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 | - Includes:
96 | - HappyMapper
97 |
98 |
99 |
100 |
101 |
102 | - Defined in:
103 | - lib/invoicexpress/models/user.rb
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
Method Summary
124 |
125 |
Methods inherited from BaseModel
126 |
#initialize
127 |
133 |
134 |
135 |
136 |
137 |
142 |
143 |
144 |
--------------------------------------------------------------------------------
/doc/yard/Invoicexpress/Models/Message.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 | Class: Invoicexpress::Models::Message
8 |
9 | — Documentation by YARD 0.8.5
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
63 |
64 |
65 |
66 | Class: Invoicexpress::Models::Message
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | - Inherits:
75 | -
76 | BaseModel
77 |
78 |
79 | - Object
80 |
81 | - BaseModel
82 |
83 | - Invoicexpress::Models::Message
84 |
85 |
86 | show all
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 | - Includes:
96 | - HappyMapper
97 |
98 |
99 |
100 |
101 |
102 | - Defined in:
103 | - lib/invoicexpress/models/invoice.rb
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
Method Summary
124 |
125 |
Methods inherited from BaseModel
126 |
#initialize
127 |
133 |
134 |
135 |
136 |
137 |
142 |
143 |
144 |
--------------------------------------------------------------------------------
/doc/yard/Invoicexpress/Models/Invoices.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 | Class: Invoicexpress::Models::Invoices
8 |
9 | — Documentation by YARD 0.8.5
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
63 |
64 |
65 |
66 | Class: Invoicexpress::Models::Invoices
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | - Inherits:
75 | -
76 | BaseModel
77 |
78 |
79 | - Object
80 |
81 | - BaseModel
82 |
83 | - Invoicexpress::Models::Invoices
84 |
85 |
86 | show all
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 | - Includes:
96 | - HappyMapper
97 |
98 |
99 |
100 |
101 |
102 | - Defined in:
103 | - lib/invoicexpress/models/invoice.rb
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
Method Summary
124 |
125 |
Methods inherited from BaseModel
126 |
#initialize
127 |
133 |
134 |
135 |
136 |
137 |
142 |
143 |
144 |
--------------------------------------------------------------------------------
/doc/yard/Invoicexpress/Models/Sequence.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 | Class: Invoicexpress::Models::Sequence
8 |
9 | — Documentation by YARD 0.8.5
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
63 |
64 |
65 |
66 | Class: Invoicexpress::Models::Sequence
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | - Inherits:
75 | -
76 | BaseModel
77 |
78 |
79 | - Object
80 |
81 | - BaseModel
82 |
83 | - Invoicexpress::Models::Sequence
84 |
85 |
86 | show all
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 | - Includes:
96 | - HappyMapper
97 |
98 |
99 |
100 |
101 |
102 | - Defined in:
103 | - lib/invoicexpress/models/sequence.rb
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
Method Summary
124 |
125 |
Methods inherited from BaseModel
126 |
#initialize
127 |
133 |
134 |
135 |
136 |
137 |
142 |
143 |
144 |
--------------------------------------------------------------------------------
/doc/yard/Invoicexpress/Models/Supplier.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 | Class: Invoicexpress::Models::Supplier
8 |
9 | — Documentation by YARD 0.8.5
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
63 |
64 |
65 |
66 | Class: Invoicexpress::Models::Supplier
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | - Inherits:
75 | -
76 | BaseModel
77 |
78 |
79 | - Object
80 |
81 | - BaseModel
82 |
83 | - Invoicexpress::Models::Supplier
84 |
85 |
86 | show all
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 | - Includes:
96 | - HappyMapper
97 |
98 |
99 |
100 |
101 |
102 | - Defined in:
103 | - lib/invoicexpress/models/supplier.rb
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
Method Summary
124 |
125 |
Methods inherited from BaseModel
126 |
#initialize
127 |
133 |
134 |
135 |
136 |
137 |
142 |
143 |
144 |
--------------------------------------------------------------------------------
/doc/yard/Invoicexpress/Models/Schedules.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 | Class: Invoicexpress::Models::Schedules
8 |
9 | — Documentation by YARD 0.8.5
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
63 |
64 |
65 |
66 | Class: Invoicexpress::Models::Schedules
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | - Inherits:
75 | -
76 | BaseModel
77 |
78 |
79 | - Object
80 |
81 | - BaseModel
82 |
83 | - Invoicexpress::Models::Schedules
84 |
85 |
86 | show all
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 | - Includes:
96 | - HappyMapper
97 |
98 |
99 |
100 |
101 |
102 | - Defined in:
103 | - lib/invoicexpress/models/schedule.rb
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
Method Summary
124 |
125 |
Methods inherited from BaseModel
126 |
#initialize
127 |
133 |
134 |
135 |
136 |
137 |
142 |
143 |
144 |
--------------------------------------------------------------------------------
/doc/yard/Invoicexpress/Models/TopClient.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 | Class: Invoicexpress::Models::TopClient
8 |
9 | — Documentation by YARD 0.8.5
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
63 |
64 |
65 |
66 | Class: Invoicexpress::Models::TopClient
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | - Inherits:
75 | -
76 | BaseModel
77 |
78 |
79 | - Object
80 |
81 | - BaseModel
82 |
83 | - Invoicexpress::Models::TopClient
84 |
85 |
86 | show all
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 | - Includes:
96 | - HappyMapper
97 |
98 |
99 |
100 |
101 |
102 | - Defined in:
103 | - lib/invoicexpress/models/top_client.rb
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
Method Summary
124 |
125 |
Methods inherited from BaseModel
126 |
#initialize
127 |
133 |
134 |
135 |
136 |
137 |
142 |
143 |
144 |
--------------------------------------------------------------------------------
/doc/yard/Invoicexpress/Models/TopDebtor.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 | Class: Invoicexpress::Models::TopDebtor
8 |
9 | — Documentation by YARD 0.8.5
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
63 |
64 |
65 |
66 | Class: Invoicexpress::Models::TopDebtor
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | - Inherits:
75 | -
76 | BaseModel
77 |
78 |
79 | - Object
80 |
81 | - BaseModel
82 |
83 | - Invoicexpress::Models::TopDebtor
84 |
85 |
86 | show all
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 | - Includes:
96 | - HappyMapper
97 |
98 |
99 |
100 |
101 |
102 | - Defined in:
103 | - lib/invoicexpress/models/top_debtor.rb
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
Method Summary
124 |
125 |
Methods inherited from BaseModel
126 |
#initialize
127 |
133 |
134 |
135 |
136 |
137 |
142 |
143 |
144 |
--------------------------------------------------------------------------------
/doc/yard/Invoicexpress/Models/Credentials.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 | Class: Invoicexpress::Models::Credentials
8 |
9 | — Documentation by YARD 0.8.5
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
63 |
64 |
65 |
66 | Class: Invoicexpress::Models::Credentials
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | - Inherits:
75 | -
76 | BaseModel
77 |
78 |
79 | - Object
80 |
81 | - BaseModel
82 |
83 | - Invoicexpress::Models::Credentials
84 |
85 |
86 | show all
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 | - Includes:
96 | - HappyMapper
97 |
98 |
99 |
100 |
101 |
102 | - Defined in:
103 | - lib/invoicexpress/models/user.rb
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
Method Summary
124 |
125 |
Methods inherited from BaseModel
126 |
#initialize
127 |
133 |
134 |
135 |
136 |
137 |
142 |
143 |
144 |
--------------------------------------------------------------------------------
/doc/yard/Invoicexpress/Models/CreditNotes.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 | Class: Invoicexpress::Models::CreditNotes
8 |
9 | — Documentation by YARD 0.8.5
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
63 |
64 |
65 |
66 | Class: Invoicexpress::Models::CreditNotes
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | - Inherits:
75 | -
76 | BaseModel
77 |
78 |
79 | - Object
80 |
81 | - BaseModel
82 |
83 | - Invoicexpress::Models::CreditNotes
84 |
85 |
86 | show all
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 | - Includes:
96 | - HappyMapper
97 |
98 |
99 |
100 |
101 |
102 | - Defined in:
103 | - lib/invoicexpress/models/invoice.rb
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
Method Summary
124 |
125 |
Methods inherited from BaseModel
126 |
#initialize
127 |
133 |
134 |
135 |
136 |
137 |
142 |
143 |
144 |
--------------------------------------------------------------------------------