invoiced 0.12.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +3 -1
- data/.travis.yml +5 -1
- data/Gemfile +6 -2
- data/README.md +4 -2
- data/invoiced.gemspec +2 -8
- data/lib/invoiced.rb +43 -5
- data/lib/invoiced/attachment.rb +1 -0
- data/lib/invoiced/bank_account.rb +6 -0
- data/lib/invoiced/card.rb +6 -0
- data/lib/invoiced/catalog_item.rb +2 -0
- data/lib/invoiced/charge.rb +12 -0
- data/lib/invoiced/contact.rb +2 -0
- data/lib/invoiced/coupon.rb +10 -0
- data/lib/invoiced/credit_note.rb +10 -0
- data/lib/invoiced/customer.rb +36 -0
- data/lib/invoiced/email.rb +1 -0
- data/lib/invoiced/estimate.rb +10 -0
- data/lib/invoiced/event.rb +2 -0
- data/lib/invoiced/file.rb +2 -0
- data/lib/invoiced/invoice.rb +33 -1
- data/lib/invoiced/letter.rb +5 -0
- data/lib/invoiced/line_item.rb +2 -0
- data/lib/invoiced/note.rb +10 -0
- data/lib/invoiced/object.rb +11 -5
- data/lib/invoiced/operations/create.rb +1 -1
- data/lib/invoiced/payment.rb +18 -0
- data/lib/invoiced/payment_plan.rb +2 -0
- data/lib/invoiced/payment_source.rb +8 -0
- data/lib/invoiced/payment_source_object.rb +5 -0
- data/lib/invoiced/plan.rb +2 -0
- data/lib/invoiced/refund.rb +11 -0
- data/lib/invoiced/subscription.rb +8 -0
- data/lib/invoiced/task.rb +10 -0
- data/lib/invoiced/tax_rate.rb +10 -0
- data/lib/invoiced/text_message.rb +5 -0
- data/lib/invoiced/transaction.rb +8 -0
- data/lib/invoiced/util.rb +13 -1
- data/lib/invoiced/version.rb +1 -1
- data/test/invoiced/charge_test.rb +25 -0
- data/test/invoiced/coupon_test.rb +90 -0
- data/test/invoiced/credit_note_test.rb +14 -0
- data/test/invoiced/customer_test.rb +101 -2
- data/test/invoiced/estimate_test.rb +14 -0
- data/test/invoiced/invoice_test.rb +69 -1
- data/test/invoiced/invoiced_test.rb +27 -1
- data/test/invoiced/note_test.rb +90 -0
- data/test/invoiced/payment_source_test.rb +57 -0
- data/test/invoiced/payment_test.rb +107 -0
- data/test/invoiced/refund_test.rb +25 -0
- data/test/invoiced/subscription_test.rb +13 -0
- data/test/invoiced/task_test.rb +90 -0
- data/test/invoiced/tax_rate_test.rb +90 -0
- data/test/invoiced/transaction_test.rb +15 -0
- metadata +36 -78
@@ -0,0 +1,90 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Invoiced
|
4
|
+
class TaxRateTest < Test::Unit::TestCase
|
5
|
+
should "return the api endpoint" do
|
6
|
+
tax_rate = TaxRate.new(@client, "test")
|
7
|
+
assert_equal('/tax_rates/test', tax_rate.endpoint())
|
8
|
+
end
|
9
|
+
|
10
|
+
should "create a tax rate" do
|
11
|
+
mockResponse = mock('RestClient::Response')
|
12
|
+
mockResponse.stubs(:code).returns(201)
|
13
|
+
mockResponse.stubs(:body).returns('{"id":"test","name":"Test TaxRate"}')
|
14
|
+
mockResponse.stubs(:headers).returns({})
|
15
|
+
|
16
|
+
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
17
|
+
|
18
|
+
tax_rate = @client.TaxRate.create({:name => "Test TaxRate"})
|
19
|
+
|
20
|
+
assert_instance_of(Invoiced::TaxRate, tax_rate)
|
21
|
+
assert_equal("test", tax_rate.id)
|
22
|
+
assert_equal('Test TaxRate', tax_rate.name)
|
23
|
+
end
|
24
|
+
|
25
|
+
should "retrieve a tax rate" do
|
26
|
+
mockResponse = mock('RestClient::Response')
|
27
|
+
mockResponse.stubs(:code).returns(200)
|
28
|
+
mockResponse.stubs(:body).returns('{"id":"test","name":"Test TaxRate"}')
|
29
|
+
mockResponse.stubs(:headers).returns({})
|
30
|
+
|
31
|
+
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
32
|
+
|
33
|
+
tax_rate = @client.TaxRate.retrieve("test")
|
34
|
+
|
35
|
+
assert_instance_of(Invoiced::TaxRate, tax_rate)
|
36
|
+
assert_equal("test", tax_rate.id)
|
37
|
+
assert_equal('Test TaxRate', tax_rate.name)
|
38
|
+
end
|
39
|
+
|
40
|
+
should "not update a tax rate when no params" do
|
41
|
+
tax_rate = TaxRate.new(@client, "test")
|
42
|
+
assert_false(tax_rate.save)
|
43
|
+
end
|
44
|
+
|
45
|
+
should "update a tax rate" do
|
46
|
+
mockResponse = mock('RestClient::Response')
|
47
|
+
mockResponse.stubs(:code).returns(200)
|
48
|
+
mockResponse.stubs(:body).returns('{"id":"test","name":"new contents"}')
|
49
|
+
mockResponse.stubs(:headers).returns({})
|
50
|
+
|
51
|
+
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
52
|
+
|
53
|
+
tax_rate = TaxRate.new(@client, "test")
|
54
|
+
tax_rate.name = "new contents"
|
55
|
+
assert_true(tax_rate.save)
|
56
|
+
|
57
|
+
assert_equal(tax_rate.name, 'new contents')
|
58
|
+
end
|
59
|
+
|
60
|
+
should "list all tax rates" do
|
61
|
+
mockResponse = mock('RestClient::Response')
|
62
|
+
mockResponse.stubs(:code).returns(200)
|
63
|
+
mockResponse.stubs(:body).returns('[{"id":"test","name":"Test TaxRate"}]')
|
64
|
+
mockResponse.stubs(:headers).returns(:x_total_count => 15, :link => '<https://api.invoiced.com/tax_rates?per_page=25&page=1>; rel="self", <https://api.invoiced.com/tax_rates?per_page=25&page=1>; rel="first", <https://api.invoiced.com/tax_rates?per_page=25&page=1>; rel="last"')
|
65
|
+
|
66
|
+
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
67
|
+
|
68
|
+
tax_rates, metadata = @client.TaxRate.list
|
69
|
+
|
70
|
+
assert_instance_of(Array, tax_rates)
|
71
|
+
assert_equal(1, tax_rates.length)
|
72
|
+
assert_equal("test", tax_rates[0].id)
|
73
|
+
|
74
|
+
assert_instance_of(Invoiced::List, metadata)
|
75
|
+
assert_equal(15, metadata.total_count)
|
76
|
+
end
|
77
|
+
|
78
|
+
should "delete a tax rate" do
|
79
|
+
mockResponse = mock('RestClient::Response')
|
80
|
+
mockResponse.stubs(:code).returns(204)
|
81
|
+
mockResponse.stubs(:body).returns('')
|
82
|
+
mockResponse.stubs(:headers).returns({})
|
83
|
+
|
84
|
+
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
85
|
+
|
86
|
+
tax_rate = TaxRate.new(@client, "test")
|
87
|
+
assert_true(tax_rate.delete)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -118,5 +118,20 @@ module Invoiced
|
|
118
118
|
assert_instance_of(Invoiced::Transaction, refund)
|
119
119
|
assert_equal(456, refund.id)
|
120
120
|
end
|
121
|
+
|
122
|
+
should "initiate a charge" do
|
123
|
+
mockResponse = mock('RestClient::Response')
|
124
|
+
mockResponse.stubs(:code).returns(201)
|
125
|
+
mockResponse.stubs(:body).returns('{"id":"a1b2c3","amount":100,"object":"charge"}')
|
126
|
+
mockResponse.stubs(:headers).returns({})
|
127
|
+
|
128
|
+
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
129
|
+
|
130
|
+
transaction = Transaction.new(@client, 1234)
|
131
|
+
charge = transaction.initiate_charge(:amount => 100, :payment_source_type => "card")
|
132
|
+
|
133
|
+
assert_instance_of(Invoiced::Transaction, charge)
|
134
|
+
assert_equal(charge.id, "a1b2c3")
|
135
|
+
end
|
121
136
|
end
|
122
137
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: invoiced
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jared King
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -25,89 +25,19 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 2.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: jwt
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: '2.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: activesupport
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 4.2.3
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 4.2.3
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: mocha
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 0.13.2
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: 0.13.2
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: shoulda
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 3.4.0
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 3.4.0
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: test-unit
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: rake
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
40
|
+
version: '2.0'
|
111
41
|
description: Invoiced makes invoicing and recurring billing dead simple
|
112
42
|
email: support@invoiced.com
|
113
43
|
executables: []
|
@@ -123,8 +53,12 @@ files:
|
|
123
53
|
- invoiced.gemspec
|
124
54
|
- lib/invoiced.rb
|
125
55
|
- lib/invoiced/attachment.rb
|
56
|
+
- lib/invoiced/bank_account.rb
|
57
|
+
- lib/invoiced/card.rb
|
126
58
|
- lib/invoiced/catalog_item.rb
|
59
|
+
- lib/invoiced/charge.rb
|
127
60
|
- lib/invoiced/contact.rb
|
61
|
+
- lib/invoiced/coupon.rb
|
128
62
|
- lib/invoiced/credit_note.rb
|
129
63
|
- lib/invoiced/customer.rb
|
130
64
|
- lib/invoiced/email.rb
|
@@ -138,21 +72,32 @@ files:
|
|
138
72
|
- lib/invoiced/event.rb
|
139
73
|
- lib/invoiced/file.rb
|
140
74
|
- lib/invoiced/invoice.rb
|
75
|
+
- lib/invoiced/letter.rb
|
141
76
|
- lib/invoiced/line_item.rb
|
142
77
|
- lib/invoiced/list.rb
|
78
|
+
- lib/invoiced/note.rb
|
143
79
|
- lib/invoiced/object.rb
|
144
80
|
- lib/invoiced/operations/create.rb
|
145
81
|
- lib/invoiced/operations/delete.rb
|
146
82
|
- lib/invoiced/operations/list.rb
|
147
83
|
- lib/invoiced/operations/update.rb
|
84
|
+
- lib/invoiced/payment.rb
|
148
85
|
- lib/invoiced/payment_plan.rb
|
86
|
+
- lib/invoiced/payment_source.rb
|
87
|
+
- lib/invoiced/payment_source_object.rb
|
149
88
|
- lib/invoiced/plan.rb
|
89
|
+
- lib/invoiced/refund.rb
|
150
90
|
- lib/invoiced/subscription.rb
|
91
|
+
- lib/invoiced/task.rb
|
92
|
+
- lib/invoiced/tax_rate.rb
|
93
|
+
- lib/invoiced/text_message.rb
|
151
94
|
- lib/invoiced/transaction.rb
|
152
95
|
- lib/invoiced/util.rb
|
153
96
|
- lib/invoiced/version.rb
|
154
97
|
- test/invoiced/catalog_item_test.rb
|
98
|
+
- test/invoiced/charge_test.rb
|
155
99
|
- test/invoiced/contact_test.rb
|
100
|
+
- test/invoiced/coupon_test.rb
|
156
101
|
- test/invoiced/credit_note_test.rb
|
157
102
|
- test/invoiced/customer_test.rb
|
158
103
|
- test/invoiced/error_test.rb
|
@@ -162,10 +107,16 @@ files:
|
|
162
107
|
- test/invoiced/invoice_test.rb
|
163
108
|
- test/invoiced/invoiced_test.rb
|
164
109
|
- test/invoiced/line_item_test.rb
|
110
|
+
- test/invoiced/note_test.rb
|
165
111
|
- test/invoiced/object_test.rb
|
166
112
|
- test/invoiced/payment_plan_test.rb
|
113
|
+
- test/invoiced/payment_source_test.rb
|
114
|
+
- test/invoiced/payment_test.rb
|
167
115
|
- test/invoiced/plan_test.rb
|
116
|
+
- test/invoiced/refund_test.rb
|
168
117
|
- test/invoiced/subscription_test.rb
|
118
|
+
- test/invoiced/task_test.rb
|
119
|
+
- test/invoiced/tax_rate_test.rb
|
169
120
|
- test/invoiced/transaction_test.rb
|
170
121
|
- test/invoiced/util_test.rb
|
171
122
|
- test/test_helper.rb
|
@@ -181,21 +132,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
181
132
|
requirements:
|
182
133
|
- - ">="
|
183
134
|
- !ruby/object:Gem::Version
|
184
|
-
version: 2.
|
135
|
+
version: 2.1.0
|
185
136
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
186
137
|
requirements:
|
187
138
|
- - ">="
|
188
139
|
- !ruby/object:Gem::Version
|
189
140
|
version: '0'
|
190
141
|
requirements: []
|
191
|
-
|
192
|
-
rubygems_version: 2.2.2
|
142
|
+
rubygems_version: 3.1.4
|
193
143
|
signing_key:
|
194
144
|
specification_version: 4
|
195
145
|
summary: Ruby client library for the Invoiced API
|
196
146
|
test_files:
|
197
147
|
- test/invoiced/catalog_item_test.rb
|
148
|
+
- test/invoiced/charge_test.rb
|
198
149
|
- test/invoiced/contact_test.rb
|
150
|
+
- test/invoiced/coupon_test.rb
|
199
151
|
- test/invoiced/credit_note_test.rb
|
200
152
|
- test/invoiced/customer_test.rb
|
201
153
|
- test/invoiced/error_test.rb
|
@@ -205,10 +157,16 @@ test_files:
|
|
205
157
|
- test/invoiced/invoice_test.rb
|
206
158
|
- test/invoiced/invoiced_test.rb
|
207
159
|
- test/invoiced/line_item_test.rb
|
160
|
+
- test/invoiced/note_test.rb
|
208
161
|
- test/invoiced/object_test.rb
|
209
162
|
- test/invoiced/payment_plan_test.rb
|
163
|
+
- test/invoiced/payment_source_test.rb
|
164
|
+
- test/invoiced/payment_test.rb
|
210
165
|
- test/invoiced/plan_test.rb
|
166
|
+
- test/invoiced/refund_test.rb
|
211
167
|
- test/invoiced/subscription_test.rb
|
168
|
+
- test/invoiced/task_test.rb
|
169
|
+
- test/invoiced/tax_rate_test.rb
|
212
170
|
- test/invoiced/transaction_test.rb
|
213
171
|
- test/invoiced/util_test.rb
|
214
172
|
- test/test_helper.rb
|