invoiced 1.1.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +35 -0
- data/Gemfile +2 -2
- data/README.md +21 -5
- data/lib/invoiced/bank_account.rb +0 -1
- data/lib/invoiced/card.rb +0 -1
- data/lib/invoiced/charge.rb +12 -0
- data/lib/invoiced/credit_balance_adjustment.rb +10 -0
- data/lib/invoiced/custom_field.rb +10 -0
- data/lib/invoiced/customer_chasing_cadence.rb +10 -0
- data/lib/invoiced/email_template.rb +10 -0
- data/lib/invoiced/gl_account.rb +10 -0
- data/lib/invoiced/inbox.rb +7 -0
- data/lib/invoiced/invoice_chasing_cadence.rb +10 -0
- data/lib/invoiced/{catalog_item.rb → item.rb} +2 -2
- data/lib/invoiced/late_fee_schedule.rb +10 -0
- data/lib/invoiced/member.rb +10 -0
- data/lib/invoiced/merchant_account.rb +10 -0
- data/lib/invoiced/object.rb +5 -1
- data/lib/invoiced/{transaction.rb → payment.rb} +2 -14
- data/lib/invoiced/payment_method.rb +8 -0
- data/lib/invoiced/pdf_template.rb +10 -0
- data/lib/invoiced/refund.rb +11 -0
- data/lib/invoiced/report.rb +7 -0
- data/lib/invoiced/role.rb +10 -0
- data/lib/invoiced/sign_up_page.rb +10 -0
- data/lib/invoiced/sms_template.rb +10 -0
- data/lib/invoiced/tax_rule.rb +10 -0
- data/lib/invoiced/theme.rb +10 -0
- data/lib/invoiced/version.rb +1 -1
- data/lib/invoiced/webhook.rb +10 -0
- data/lib/invoiced.rb +48 -5
- data/test/invoiced/charge_test.rb +27 -0
- data/test/invoiced/contact_test.rb +10 -86
- data/test/invoiced/coupon_test.rb +10 -83
- data/test/invoiced/credit_balance_adjustment_test.rb +17 -0
- data/test/invoiced/credit_note_test.rb +10 -83
- data/test/invoiced/custom_field_test.rb +17 -0
- data/test/invoiced/customer_chasing_cadence_test.rb +17 -0
- data/test/invoiced/customer_test.rb +10 -83
- data/test/invoiced/email_template_test.rb +17 -0
- data/test/invoiced/estimate_test.rb +10 -83
- data/test/invoiced/event_test.rb +6 -21
- data/test/invoiced/file_test.rb +8 -47
- data/test/invoiced/gl_account_test.rb +17 -0
- data/test/invoiced/inbox_test.rb +13 -0
- data/test/invoiced/invoice_chasing_cadence_test.rb +17 -0
- data/test/invoiced/invoice_test.rb +10 -83
- data/test/invoiced/item_test.rb +17 -0
- data/test/invoiced/late_fee_schedule_test.rb +17 -0
- data/test/invoiced/line_item_test.rb +10 -86
- data/test/invoiced/member_test.rb +17 -0
- data/test/invoiced/merchant_account_test.rb +17 -0
- data/test/invoiced/note_test.rb +10 -83
- data/test/invoiced/operations/create_test.rb +22 -0
- data/test/invoiced/operations/delete_test.rb +20 -0
- data/test/invoiced/operations/endpoint_test.rb +13 -0
- data/test/invoiced/operations/list_test.rb +26 -0
- data/test/invoiced/operations/operations.rb +0 -0
- data/test/invoiced/operations/retrieve_test.rb +22 -0
- data/test/invoiced/operations/update_test.rb +29 -0
- data/test/invoiced/payment_method_test.rb +15 -0
- data/test/invoiced/payment_plan_test.rb +7 -0
- data/test/invoiced/payment_test.rb +34 -0
- data/test/invoiced/pdf_template_test.rb +17 -0
- data/test/invoiced/plan_test.rb +10 -83
- data/test/invoiced/refund_test.rb +27 -0
- data/test/invoiced/report_test.rb +14 -0
- data/test/invoiced/role_test.rb +17 -0
- data/test/invoiced/sign_up_page_test.rb +17 -0
- data/test/invoiced/sms_template_test.rb +17 -0
- data/test/invoiced/subscription_test.rb +10 -71
- data/test/invoiced/task_test.rb +10 -83
- data/test/invoiced/tax_rate_test.rb +10 -83
- data/test/invoiced/tax_rule_test.rb +17 -0
- data/test/invoiced/theme_test.rb +17 -0
- data/test/invoiced/webhook_test.rb +17 -0
- data/test/test_helper.rb +6 -0
- metadata +90 -13
- data/.travis.yml +0 -12
- data/test/invoiced/catalog_item_test.rb +0 -90
- data/test/invoiced/transaction_test.rb +0 -137
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: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jared King
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -44,8 +44,8 @@ executables: []
|
|
44
44
|
extensions: []
|
45
45
|
extra_rdoc_files: []
|
46
46
|
files:
|
47
|
+
- ".github/workflows/ci.yml"
|
47
48
|
- ".gitignore"
|
48
|
-
- ".travis.yml"
|
49
49
|
- Gemfile
|
50
50
|
- LICENSE
|
51
51
|
- README.md
|
@@ -55,12 +55,16 @@ files:
|
|
55
55
|
- lib/invoiced/attachment.rb
|
56
56
|
- lib/invoiced/bank_account.rb
|
57
57
|
- lib/invoiced/card.rb
|
58
|
-
- lib/invoiced/
|
58
|
+
- lib/invoiced/charge.rb
|
59
59
|
- lib/invoiced/contact.rb
|
60
60
|
- lib/invoiced/coupon.rb
|
61
|
+
- lib/invoiced/credit_balance_adjustment.rb
|
61
62
|
- lib/invoiced/credit_note.rb
|
63
|
+
- lib/invoiced/custom_field.rb
|
62
64
|
- lib/invoiced/customer.rb
|
65
|
+
- lib/invoiced/customer_chasing_cadence.rb
|
63
66
|
- lib/invoiced/email.rb
|
67
|
+
- lib/invoiced/email_template.rb
|
64
68
|
- lib/invoiced/error/api_connection_error.rb
|
65
69
|
- lib/invoiced/error/api_error.rb
|
66
70
|
- lib/invoiced/error/authentication_error.rb
|
@@ -70,55 +74,100 @@ files:
|
|
70
74
|
- lib/invoiced/estimate.rb
|
71
75
|
- lib/invoiced/event.rb
|
72
76
|
- lib/invoiced/file.rb
|
77
|
+
- lib/invoiced/gl_account.rb
|
78
|
+
- lib/invoiced/inbox.rb
|
73
79
|
- lib/invoiced/invoice.rb
|
80
|
+
- lib/invoiced/invoice_chasing_cadence.rb
|
81
|
+
- lib/invoiced/item.rb
|
82
|
+
- lib/invoiced/late_fee_schedule.rb
|
74
83
|
- lib/invoiced/letter.rb
|
75
84
|
- lib/invoiced/line_item.rb
|
76
85
|
- lib/invoiced/list.rb
|
86
|
+
- lib/invoiced/member.rb
|
87
|
+
- lib/invoiced/merchant_account.rb
|
77
88
|
- lib/invoiced/note.rb
|
78
89
|
- lib/invoiced/object.rb
|
79
90
|
- lib/invoiced/operations/create.rb
|
80
91
|
- lib/invoiced/operations/delete.rb
|
81
92
|
- lib/invoiced/operations/list.rb
|
82
93
|
- lib/invoiced/operations/update.rb
|
94
|
+
- lib/invoiced/payment.rb
|
95
|
+
- lib/invoiced/payment_method.rb
|
83
96
|
- lib/invoiced/payment_plan.rb
|
84
97
|
- lib/invoiced/payment_source.rb
|
85
98
|
- lib/invoiced/payment_source_object.rb
|
99
|
+
- lib/invoiced/pdf_template.rb
|
86
100
|
- lib/invoiced/plan.rb
|
101
|
+
- lib/invoiced/refund.rb
|
102
|
+
- lib/invoiced/report.rb
|
103
|
+
- lib/invoiced/role.rb
|
104
|
+
- lib/invoiced/sign_up_page.rb
|
105
|
+
- lib/invoiced/sms_template.rb
|
87
106
|
- lib/invoiced/subscription.rb
|
88
107
|
- lib/invoiced/task.rb
|
89
108
|
- lib/invoiced/tax_rate.rb
|
109
|
+
- lib/invoiced/tax_rule.rb
|
90
110
|
- lib/invoiced/text_message.rb
|
91
|
-
- lib/invoiced/
|
111
|
+
- lib/invoiced/theme.rb
|
92
112
|
- lib/invoiced/util.rb
|
93
113
|
- lib/invoiced/version.rb
|
94
|
-
-
|
114
|
+
- lib/invoiced/webhook.rb
|
115
|
+
- test/invoiced/charge_test.rb
|
95
116
|
- test/invoiced/contact_test.rb
|
96
117
|
- test/invoiced/coupon_test.rb
|
118
|
+
- test/invoiced/credit_balance_adjustment_test.rb
|
97
119
|
- test/invoiced/credit_note_test.rb
|
120
|
+
- test/invoiced/custom_field_test.rb
|
121
|
+
- test/invoiced/customer_chasing_cadence_test.rb
|
98
122
|
- test/invoiced/customer_test.rb
|
123
|
+
- test/invoiced/email_template_test.rb
|
99
124
|
- test/invoiced/error_test.rb
|
100
125
|
- test/invoiced/estimate_test.rb
|
101
126
|
- test/invoiced/event_test.rb
|
102
127
|
- test/invoiced/file_test.rb
|
128
|
+
- test/invoiced/gl_account_test.rb
|
129
|
+
- test/invoiced/inbox_test.rb
|
130
|
+
- test/invoiced/invoice_chasing_cadence_test.rb
|
103
131
|
- test/invoiced/invoice_test.rb
|
104
132
|
- test/invoiced/invoiced_test.rb
|
133
|
+
- test/invoiced/item_test.rb
|
134
|
+
- test/invoiced/late_fee_schedule_test.rb
|
105
135
|
- test/invoiced/line_item_test.rb
|
136
|
+
- test/invoiced/member_test.rb
|
137
|
+
- test/invoiced/merchant_account_test.rb
|
106
138
|
- test/invoiced/note_test.rb
|
107
139
|
- test/invoiced/object_test.rb
|
140
|
+
- test/invoiced/operations/create_test.rb
|
141
|
+
- test/invoiced/operations/delete_test.rb
|
142
|
+
- test/invoiced/operations/endpoint_test.rb
|
143
|
+
- test/invoiced/operations/list_test.rb
|
144
|
+
- test/invoiced/operations/operations.rb
|
145
|
+
- test/invoiced/operations/retrieve_test.rb
|
146
|
+
- test/invoiced/operations/update_test.rb
|
147
|
+
- test/invoiced/payment_method_test.rb
|
108
148
|
- test/invoiced/payment_plan_test.rb
|
109
149
|
- test/invoiced/payment_source_test.rb
|
150
|
+
- test/invoiced/payment_test.rb
|
151
|
+
- test/invoiced/pdf_template_test.rb
|
110
152
|
- test/invoiced/plan_test.rb
|
153
|
+
- test/invoiced/refund_test.rb
|
154
|
+
- test/invoiced/report_test.rb
|
155
|
+
- test/invoiced/role_test.rb
|
156
|
+
- test/invoiced/sign_up_page_test.rb
|
157
|
+
- test/invoiced/sms_template_test.rb
|
111
158
|
- test/invoiced/subscription_test.rb
|
112
159
|
- test/invoiced/task_test.rb
|
113
160
|
- test/invoiced/tax_rate_test.rb
|
114
|
-
- test/invoiced/
|
161
|
+
- test/invoiced/tax_rule_test.rb
|
162
|
+
- test/invoiced/theme_test.rb
|
115
163
|
- test/invoiced/util_test.rb
|
164
|
+
- test/invoiced/webhook_test.rb
|
116
165
|
- test/test_helper.rb
|
117
166
|
homepage: https://invoiced.com/docs/dev
|
118
167
|
licenses:
|
119
168
|
- MIT
|
120
169
|
metadata: {}
|
121
|
-
post_install_message:
|
170
|
+
post_install_message:
|
122
171
|
rdoc_options: []
|
123
172
|
require_paths:
|
124
173
|
- lib
|
@@ -133,31 +182,59 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
182
|
- !ruby/object:Gem::Version
|
134
183
|
version: '0'
|
135
184
|
requirements: []
|
136
|
-
rubygems_version: 3.
|
137
|
-
signing_key:
|
185
|
+
rubygems_version: 3.1.4
|
186
|
+
signing_key:
|
138
187
|
specification_version: 4
|
139
188
|
summary: Ruby client library for the Invoiced API
|
140
189
|
test_files:
|
141
|
-
- test/invoiced/
|
190
|
+
- test/invoiced/charge_test.rb
|
142
191
|
- test/invoiced/contact_test.rb
|
143
192
|
- test/invoiced/coupon_test.rb
|
193
|
+
- test/invoiced/credit_balance_adjustment_test.rb
|
144
194
|
- test/invoiced/credit_note_test.rb
|
195
|
+
- test/invoiced/custom_field_test.rb
|
196
|
+
- test/invoiced/customer_chasing_cadence_test.rb
|
145
197
|
- test/invoiced/customer_test.rb
|
198
|
+
- test/invoiced/email_template_test.rb
|
146
199
|
- test/invoiced/error_test.rb
|
147
200
|
- test/invoiced/estimate_test.rb
|
148
201
|
- test/invoiced/event_test.rb
|
149
202
|
- test/invoiced/file_test.rb
|
203
|
+
- test/invoiced/gl_account_test.rb
|
204
|
+
- test/invoiced/inbox_test.rb
|
205
|
+
- test/invoiced/invoice_chasing_cadence_test.rb
|
150
206
|
- test/invoiced/invoice_test.rb
|
151
207
|
- test/invoiced/invoiced_test.rb
|
208
|
+
- test/invoiced/item_test.rb
|
209
|
+
- test/invoiced/late_fee_schedule_test.rb
|
152
210
|
- test/invoiced/line_item_test.rb
|
211
|
+
- test/invoiced/member_test.rb
|
212
|
+
- test/invoiced/merchant_account_test.rb
|
153
213
|
- test/invoiced/note_test.rb
|
154
214
|
- test/invoiced/object_test.rb
|
215
|
+
- test/invoiced/operations/create_test.rb
|
216
|
+
- test/invoiced/operations/delete_test.rb
|
217
|
+
- test/invoiced/operations/endpoint_test.rb
|
218
|
+
- test/invoiced/operations/list_test.rb
|
219
|
+
- test/invoiced/operations/operations.rb
|
220
|
+
- test/invoiced/operations/retrieve_test.rb
|
221
|
+
- test/invoiced/operations/update_test.rb
|
222
|
+
- test/invoiced/payment_method_test.rb
|
155
223
|
- test/invoiced/payment_plan_test.rb
|
156
224
|
- test/invoiced/payment_source_test.rb
|
225
|
+
- test/invoiced/payment_test.rb
|
226
|
+
- test/invoiced/pdf_template_test.rb
|
157
227
|
- test/invoiced/plan_test.rb
|
228
|
+
- test/invoiced/refund_test.rb
|
229
|
+
- test/invoiced/report_test.rb
|
230
|
+
- test/invoiced/role_test.rb
|
231
|
+
- test/invoiced/sign_up_page_test.rb
|
232
|
+
- test/invoiced/sms_template_test.rb
|
158
233
|
- test/invoiced/subscription_test.rb
|
159
234
|
- test/invoiced/task_test.rb
|
160
235
|
- test/invoiced/tax_rate_test.rb
|
161
|
-
- test/invoiced/
|
236
|
+
- test/invoiced/tax_rule_test.rb
|
237
|
+
- test/invoiced/theme_test.rb
|
162
238
|
- test/invoiced/util_test.rb
|
239
|
+
- test/invoiced/webhook_test.rb
|
163
240
|
- test/test_helper.rb
|
data/.travis.yml
DELETED
@@ -1,90 +0,0 @@
|
|
1
|
-
require File.expand_path('../../test_helper', __FILE__)
|
2
|
-
|
3
|
-
module Invoiced
|
4
|
-
class CatalogItemTest < Test::Unit::TestCase
|
5
|
-
should "return the api endpoint" do
|
6
|
-
catalogItem = CatalogItem.new(@client, "test")
|
7
|
-
assert_equal('/catalog_items/test', catalogItem.endpoint())
|
8
|
-
end
|
9
|
-
|
10
|
-
should "create a catalog item" do
|
11
|
-
mockResponse = mock('RestClient::Response')
|
12
|
-
mockResponse.stubs(:code).returns(201)
|
13
|
-
mockResponse.stubs(:body).returns('{"id":"test","name":"Test Item"}')
|
14
|
-
mockResponse.stubs(:headers).returns({})
|
15
|
-
|
16
|
-
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
17
|
-
|
18
|
-
catalogItem = @client.CatalogItem.create({:name => "Test Item"})
|
19
|
-
|
20
|
-
assert_instance_of(Invoiced::CatalogItem, catalogItem)
|
21
|
-
assert_equal("test", catalogItem.id)
|
22
|
-
assert_equal('Test Item', catalogItem.name)
|
23
|
-
end
|
24
|
-
|
25
|
-
should "retrieve a catalog item" do
|
26
|
-
mockResponse = mock('RestClient::Response')
|
27
|
-
mockResponse.stubs(:code).returns(200)
|
28
|
-
mockResponse.stubs(:body).returns('{"id":"test","name":"Test Item"}')
|
29
|
-
mockResponse.stubs(:headers).returns({})
|
30
|
-
|
31
|
-
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
32
|
-
|
33
|
-
catalogItem = @client.CatalogItem.retrieve("test")
|
34
|
-
|
35
|
-
assert_instance_of(Invoiced::CatalogItem, catalogItem)
|
36
|
-
assert_equal("test", catalogItem.id)
|
37
|
-
assert_equal('Test Item', catalogItem.name)
|
38
|
-
end
|
39
|
-
|
40
|
-
should "not update a catalog item when no params" do
|
41
|
-
catalogItem = CatalogItem.new(@client, "test")
|
42
|
-
assert_false(catalogItem.save)
|
43
|
-
end
|
44
|
-
|
45
|
-
should "update a catalog item" do
|
46
|
-
mockResponse = mock('RestClient::Response')
|
47
|
-
mockResponse.stubs(:code).returns(200)
|
48
|
-
mockResponse.stubs(:body).returns('{"id":"test","closed":true}')
|
49
|
-
mockResponse.stubs(:headers).returns({})
|
50
|
-
|
51
|
-
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
52
|
-
|
53
|
-
catalogItem = CatalogItem.new(@client, "test")
|
54
|
-
catalogItem.closed = true
|
55
|
-
assert_true(catalogItem.save)
|
56
|
-
|
57
|
-
assert_true(catalogItem.closed)
|
58
|
-
end
|
59
|
-
|
60
|
-
should "list all catalog items" do
|
61
|
-
mockResponse = mock('RestClient::Response')
|
62
|
-
mockResponse.stubs(:code).returns(200)
|
63
|
-
mockResponse.stubs(:body).returns('[{"id":"test","name":"Test Item"}]')
|
64
|
-
mockResponse.stubs(:headers).returns(:x_total_count => 15, :link => '<https://api.invoiced.com/catalog_items?per_page=25&page=1>; rel="self", <https://api.invoiced.com/catalog_items?per_page=25&page=1>; rel="first", <https://api.invoiced.com/catalog_items?per_page=25&page=1>; rel="last"')
|
65
|
-
|
66
|
-
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
67
|
-
|
68
|
-
catalogItems, metadata = @client.CatalogItem.list
|
69
|
-
|
70
|
-
assert_instance_of(Array, catalogItems)
|
71
|
-
assert_equal(1, catalogItems.length)
|
72
|
-
assert_equal("test", catalogItems[0].id)
|
73
|
-
|
74
|
-
assert_instance_of(Invoiced::List, metadata)
|
75
|
-
assert_equal(15, metadata.total_count)
|
76
|
-
end
|
77
|
-
|
78
|
-
should "delete a catalog item" 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
|
-
catalogItem = CatalogItem.new(@client, "test")
|
87
|
-
assert_true(catalogItem.delete)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
@@ -1,137 +0,0 @@
|
|
1
|
-
require File.expand_path('../../test_helper', __FILE__)
|
2
|
-
|
3
|
-
module Invoiced
|
4
|
-
class TransactionTest < Test::Unit::TestCase
|
5
|
-
should "return the api endpoint" do
|
6
|
-
transaction = Transaction.new(@client, 123)
|
7
|
-
assert_equal('/transactions/123', transaction.endpoint())
|
8
|
-
end
|
9
|
-
|
10
|
-
should "create a transaction" do
|
11
|
-
mockResponse = mock('RestClient::Response')
|
12
|
-
mockResponse.stubs(:code).returns(201)
|
13
|
-
mockResponse.stubs(:body).returns('{"id":123,"amount":100}')
|
14
|
-
mockResponse.stubs(:headers).returns({})
|
15
|
-
|
16
|
-
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
17
|
-
|
18
|
-
transaction = @client.Transaction.create({:amount => 800})
|
19
|
-
|
20
|
-
assert_instance_of(Invoiced::Transaction, transaction)
|
21
|
-
assert_equal(123, transaction.id)
|
22
|
-
assert_equal(100, transaction.amount)
|
23
|
-
end
|
24
|
-
|
25
|
-
should "retrieve a transaction" do
|
26
|
-
mockResponse = mock('RestClient::Response')
|
27
|
-
mockResponse.stubs(:code).returns(200)
|
28
|
-
mockResponse.stubs(:body).returns('{"id":123,"amount":100}')
|
29
|
-
mockResponse.stubs(:headers).returns({})
|
30
|
-
|
31
|
-
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
32
|
-
|
33
|
-
transaction = @client.Transaction.retrieve(123)
|
34
|
-
|
35
|
-
assert_instance_of(Invoiced::Transaction, transaction)
|
36
|
-
assert_equal(123, transaction.id)
|
37
|
-
assert_equal(100, transaction.amount)
|
38
|
-
end
|
39
|
-
|
40
|
-
should "not update a transaction when no params" do
|
41
|
-
transaction = Transaction.new(@client, 123)
|
42
|
-
assert_false(transaction.save)
|
43
|
-
end
|
44
|
-
|
45
|
-
should "update a transaction" do
|
46
|
-
mockResponse = mock('RestClient::Response')
|
47
|
-
mockResponse.stubs(:code).returns(200)
|
48
|
-
mockResponse.stubs(:body).returns('{"id":123,"sent":true}')
|
49
|
-
mockResponse.stubs(:headers).returns({})
|
50
|
-
|
51
|
-
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
52
|
-
|
53
|
-
transaction = Transaction.new(@client, 123)
|
54
|
-
transaction.sent = true
|
55
|
-
assert_true(transaction.save)
|
56
|
-
|
57
|
-
assert_true(transaction.sent)
|
58
|
-
end
|
59
|
-
|
60
|
-
should "list all transactions" do
|
61
|
-
mockResponse = mock('RestClient::Response')
|
62
|
-
mockResponse.stubs(:code).returns(200)
|
63
|
-
mockResponse.stubs(:body).returns('[{"id":123,"amount":100}]')
|
64
|
-
mockResponse.stubs(:headers).returns(:x_total_count => 15, :link => '<https://api.invoiced.com/transactions?per_page=25&page=1>; rel="self", <https://api.invoiced.com/transactions?per_page=25&page=1>; rel="first", <https://api.invoiced.com/transactions?per_page=25&page=1>; rel="last"')
|
65
|
-
|
66
|
-
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
67
|
-
|
68
|
-
transactions, metadata = @client.Transaction.list
|
69
|
-
|
70
|
-
assert_instance_of(Array, transactions)
|
71
|
-
assert_equal(1, transactions.length)
|
72
|
-
assert_equal(123, transactions[0].id)
|
73
|
-
|
74
|
-
assert_instance_of(Invoiced::List, metadata)
|
75
|
-
assert_equal(15, metadata.total_count)
|
76
|
-
end
|
77
|
-
|
78
|
-
should "delete a transaction" 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
|
-
transaction = Transaction.new(@client, 123)
|
87
|
-
assert_true(transaction.delete)
|
88
|
-
end
|
89
|
-
|
90
|
-
should "send a payment receipt" do
|
91
|
-
mockResponse = mock('RestClient::Response')
|
92
|
-
mockResponse.stubs(:code).returns(201)
|
93
|
-
mockResponse.stubs(:body).returns('[{"id":4567,"email":"test@example.com"}]')
|
94
|
-
mockResponse.stubs(:headers).returns({})
|
95
|
-
|
96
|
-
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
97
|
-
|
98
|
-
transaction = Transaction.new(@client, 1234)
|
99
|
-
emails = transaction.send
|
100
|
-
|
101
|
-
assert_instance_of(Array, emails)
|
102
|
-
assert_equal(1, emails.length)
|
103
|
-
assert_instance_of(Invoiced::Email, emails[0])
|
104
|
-
assert_equal(4567, emails[0].id)
|
105
|
-
end
|
106
|
-
|
107
|
-
should "refund a transaction" do
|
108
|
-
mockResponse = mock('RestClient::Response')
|
109
|
-
mockResponse.stubs(:code).returns(201)
|
110
|
-
mockResponse.stubs(:body).returns('{"id":456}')
|
111
|
-
mockResponse.stubs(:headers).returns({})
|
112
|
-
|
113
|
-
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
114
|
-
|
115
|
-
transaction = Transaction.new(@client, 1234)
|
116
|
-
refund = transaction.refund({:amount => 800})
|
117
|
-
|
118
|
-
assert_instance_of(Invoiced::Transaction, refund)
|
119
|
-
assert_equal(456, refund.id)
|
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
|
136
|
-
end
|
137
|
-
end
|