easy_invoice 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +57 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/easy_invoice.gemspec +36 -0
- data/lib/easy_invoice.rb +7 -0
- data/lib/easy_invoice/invoice.rb +59 -0
- data/lib/easy_invoice/item.rb +11 -0
- data/lib/easy_invoice/template.rb +30 -0
- data/lib/easy_invoice/version.rb +3 -0
- metadata +143 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4c12225fef2a7bc004f4c60315cfd47abd56398c
|
4
|
+
data.tar.gz: 37d6c12b8e738549c996e4b842f7f8a18dbee4c3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 18ef146656076611f83a5cfee9496154669960b88a5a75f491dac2a946d116c6ce0c1d39f3a31fa72961ec9a9a1838ca905b8c8d8ced4302f66c4817c825bdb6
|
7
|
+
data.tar.gz: ddd33ed0160465030a09a1b341729f8896ebe8e863768d8ddded988c5ad8ec67ba95b48de92caecc116a947f8495257a21b49c51334b916edf53c45d3e7c0aef
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at edwin@homerlogistics.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 edwin
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# EasyInvoice
|
2
|
+
InvoicedLite API Wrapper for Ruby
|
3
|
+
|
4
|
+
Please look here for list of parameters:
|
5
|
+
https://github.com/Invoiced/invoice-generator-api
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'easy_invoice'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install easy_invoice
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
You can directly input `options`
|
26
|
+
```ruby
|
27
|
+
options = {
|
28
|
+
:from=>"Invoiced, Inc.",
|
29
|
+
:to=>"Parag",
|
30
|
+
:logo=>"https://invoiced.com/img/logo-invoice.png",
|
31
|
+
:number=>1,
|
32
|
+
:items=>[
|
33
|
+
{
|
34
|
+
:name=>"Starter plan",
|
35
|
+
:quantity=>1,
|
36
|
+
:unit_cost=>99
|
37
|
+
}
|
38
|
+
],
|
39
|
+
:notes=>"Thanks for your business!"
|
40
|
+
}
|
41
|
+
# Initialize Invoice
|
42
|
+
invoice = EasyInvoice::Invoice.new(options: options)
|
43
|
+
# Perform API call to retrieve pdf.
|
44
|
+
invoice.generate_pdf
|
45
|
+
# Pdf data is stored in invoice.pdf
|
46
|
+
invoice.pdf
|
47
|
+
```
|
48
|
+
|
49
|
+
Or you can define `EasyInvoice::Template` and `EasyInvoice::Item` and pass them into the initialization
|
50
|
+
```ruby
|
51
|
+
template = EasyInvoice::Template.new({currency: "USD", header: "Custom Header"})
|
52
|
+
item = EasyInvoice::Item.new({name: "Item1", quantity: 5, unit_cost: "5"})
|
53
|
+
|
54
|
+
invoice = EasyInvoice::Invoice.new(template: template, items: [item])
|
55
|
+
invoice.generate_pdf
|
56
|
+
invoice.pdf
|
57
|
+
```
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "easy_invoice"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'easy_invoice/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "easy_invoice"
|
8
|
+
spec.version = EasyInvoice::VERSION
|
9
|
+
spec.authors = ["edwin"]
|
10
|
+
spec.email = ["cintosyntax@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{InvoicedLite API Wrapper for Ruby}
|
13
|
+
spec.homepage = "https://github.com/cintosyntax/easy_invoice"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
17
|
+
# delete this section to allow pushing this gem to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
20
|
+
else
|
21
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
22
|
+
end
|
23
|
+
|
24
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
spec.bindir = "exe"
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ["lib"]
|
28
|
+
|
29
|
+
spec.add_dependency "excon", "~> 0.48.0"
|
30
|
+
spec.add_dependency "json", "~> 1.8", ">= 1.8.3"
|
31
|
+
|
32
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
33
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
34
|
+
spec.add_development_dependency "minitest", "~> 5.8", ">= 5.8.4"
|
35
|
+
|
36
|
+
end
|
data/lib/easy_invoice.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require "excon"
|
2
|
+
require "virtus"
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
require_relative "item"
|
6
|
+
require_relative "template"
|
7
|
+
|
8
|
+
BASE_URL = "http://invoice-generator.com"
|
9
|
+
|
10
|
+
module EasyInvoice
|
11
|
+
class Invoice
|
12
|
+
include Virtus.model
|
13
|
+
|
14
|
+
attribute :items, Array[EasyInvoice::Item]
|
15
|
+
attribute :template, EasyInvoice::Template
|
16
|
+
attribute :options, Hash
|
17
|
+
attribute :currency, String
|
18
|
+
attribute :logo, String
|
19
|
+
attribute :from, String
|
20
|
+
attribute :to, String
|
21
|
+
attribute :number, String
|
22
|
+
attribute :purchase_order, String
|
23
|
+
attribute :due_date, String
|
24
|
+
attribute :discounts, Integer
|
25
|
+
attribute :tax, Integer
|
26
|
+
attribute :shipping, Integer
|
27
|
+
attribute :amount_paid, Integer
|
28
|
+
attribute :notes, String
|
29
|
+
attribute :terms, String
|
30
|
+
attribute :pdf, String
|
31
|
+
|
32
|
+
def generate_pdf
|
33
|
+
response = Excon.post(BASE_URL, body: self.payload.to_s, headers: {"Content-Type" => "application/json"})
|
34
|
+
if response.status == 200
|
35
|
+
self.pdf = response.body
|
36
|
+
return true
|
37
|
+
else
|
38
|
+
return false
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def payload
|
43
|
+
payload = self.attributes.select { |k,v| v.is_a?(String) || v.is_a?(Integer) }
|
44
|
+
|
45
|
+
payload[:items] = self.items.map { |item| item.attributes}
|
46
|
+
|
47
|
+
unless self.template.nil?
|
48
|
+
template_attributes = self.template.attributes
|
49
|
+
payload.merge(template_attributes)
|
50
|
+
end
|
51
|
+
|
52
|
+
#Add any extra options
|
53
|
+
payload.merge(self.options)
|
54
|
+
|
55
|
+
payload.to_json
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "virtus"
|
2
|
+
|
3
|
+
module EasyInvoice
|
4
|
+
class Template
|
5
|
+
include Virtus.model
|
6
|
+
|
7
|
+
attribute :currency, String
|
8
|
+
attribute :header, String
|
9
|
+
attribute :to_title, String
|
10
|
+
attribute :invoice_number_title, String
|
11
|
+
attribute :date_title, String
|
12
|
+
attribute :payment_terms_title, String
|
13
|
+
attribute :due_date_title, String
|
14
|
+
attribute :purchase_order_title, String
|
15
|
+
attribute :quantity_header, String
|
16
|
+
attribute :item_header, String
|
17
|
+
attribute :unit_cost_header, String
|
18
|
+
attribute :amount_header, String
|
19
|
+
attribute :subtotal_title, String
|
20
|
+
attribute :discounts_title, String
|
21
|
+
attribute :tax_title, String
|
22
|
+
attribute :shipping_title, String
|
23
|
+
attribute :total_title, String
|
24
|
+
attribute :amount_paid_title, String
|
25
|
+
attribute :balance_title, String
|
26
|
+
attribute :terms_title, String
|
27
|
+
attribute :notes_title, String
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: easy_invoice
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- edwin
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: excon
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.48.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.48.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.8'
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 1.8.3
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '1.8'
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 1.8.3
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: bundler
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1.11'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '1.11'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rake
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '10.0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '10.0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: minitest
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '5.8'
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: 5.8.4
|
85
|
+
type: :development
|
86
|
+
prerelease: false
|
87
|
+
version_requirements: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - "~>"
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '5.8'
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 5.8.4
|
95
|
+
description:
|
96
|
+
email:
|
97
|
+
- cintosyntax@gmail.com
|
98
|
+
executables: []
|
99
|
+
extensions: []
|
100
|
+
extra_rdoc_files: []
|
101
|
+
files:
|
102
|
+
- ".gitignore"
|
103
|
+
- ".rspec"
|
104
|
+
- ".travis.yml"
|
105
|
+
- CODE_OF_CONDUCT.md
|
106
|
+
- Gemfile
|
107
|
+
- LICENSE.txt
|
108
|
+
- README.md
|
109
|
+
- Rakefile
|
110
|
+
- bin/console
|
111
|
+
- bin/setup
|
112
|
+
- easy_invoice.gemspec
|
113
|
+
- lib/easy_invoice.rb
|
114
|
+
- lib/easy_invoice/invoice.rb
|
115
|
+
- lib/easy_invoice/item.rb
|
116
|
+
- lib/easy_invoice/template.rb
|
117
|
+
- lib/easy_invoice/version.rb
|
118
|
+
homepage: https://github.com/cintosyntax/easy_invoice
|
119
|
+
licenses:
|
120
|
+
- MIT
|
121
|
+
metadata:
|
122
|
+
allowed_push_host: https://rubygems.org
|
123
|
+
post_install_message:
|
124
|
+
rdoc_options: []
|
125
|
+
require_paths:
|
126
|
+
- lib
|
127
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
requirements: []
|
138
|
+
rubyforge_project:
|
139
|
+
rubygems_version: 2.4.5
|
140
|
+
signing_key:
|
141
|
+
specification_version: 4
|
142
|
+
summary: InvoicedLite API Wrapper for Ruby
|
143
|
+
test_files: []
|