invoiced 0.14.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +3 -1
  3. data/.travis.yml +3 -0
  4. data/README.md +11 -4
  5. data/lib/invoiced.rb +25 -5
  6. data/lib/invoiced/bank_account.rb +6 -0
  7. data/lib/invoiced/card.rb +6 -0
  8. data/lib/invoiced/charge.rb +12 -0
  9. data/lib/invoiced/{catalog_item.rb → coupon.rb} +2 -2
  10. data/lib/invoiced/credit_balance_adjustment.rb +10 -0
  11. data/lib/invoiced/credit_note.rb +8 -0
  12. data/lib/invoiced/customer.rb +34 -0
  13. data/lib/invoiced/estimate.rb +8 -0
  14. data/lib/invoiced/invoice.rb +31 -1
  15. data/lib/invoiced/item.rb +10 -0
  16. data/lib/invoiced/letter.rb +5 -0
  17. data/lib/invoiced/note.rb +10 -0
  18. data/lib/invoiced/object.rb +2 -2
  19. data/lib/invoiced/operations/create.rb +1 -1
  20. data/lib/invoiced/{transaction.rb → payment.rb} +2 -8
  21. data/lib/invoiced/payment_source.rb +8 -0
  22. data/lib/invoiced/payment_source_object.rb +5 -0
  23. data/lib/invoiced/refund.rb +11 -0
  24. data/lib/invoiced/subscription.rb +6 -0
  25. data/lib/invoiced/task.rb +10 -0
  26. data/lib/invoiced/tax_rate.rb +10 -0
  27. data/lib/invoiced/text_message.rb +5 -0
  28. data/lib/invoiced/util.rb +13 -1
  29. data/lib/invoiced/version.rb +1 -1
  30. data/test/invoiced/charge_test.rb +25 -0
  31. data/test/invoiced/{catalog_item_test.rb → coupon_test.rb} +33 -33
  32. data/test/invoiced/credit_balance_adjustment.rb +90 -0
  33. data/test/invoiced/credit_note_test.rb +14 -0
  34. data/test/invoiced/customer_test.rb +101 -2
  35. data/test/invoiced/estimate_test.rb +14 -0
  36. data/test/invoiced/invoice_test.rb +69 -1
  37. data/test/invoiced/item_test.rb +90 -0
  38. data/test/invoiced/note_test.rb +90 -0
  39. data/test/invoiced/payment_source_test.rb +57 -0
  40. data/test/invoiced/{transaction_test.rb → payment_test.rb} +32 -47
  41. data/test/invoiced/refund_test.rb +25 -0
  42. data/test/invoiced/subscription_test.rb +13 -0
  43. data/test/invoiced/task_test.rb +90 -0
  44. data/test/invoiced/tax_rate_test.rb +90 -0
  45. metadata +38 -10
@@ -0,0 +1,25 @@
1
+ require File.expand_path('../../test_helper', __FILE__)
2
+
3
+ module Invoiced
4
+ class RefundTest < Test::Unit::TestCase
5
+ should "return the api endpoint" do
6
+ refund = Refund.new(@client, 123)
7
+ assert_equal('/refunds/123', refund.endpoint())
8
+ end
9
+
10
+ should "create a refund" do
11
+ mockResponse = mock('RestClient::Response')
12
+ mockResponse.stubs(:code).returns(201)
13
+ mockResponse.stubs(:body).returns('{"id":456}')
14
+ mockResponse.stubs(:headers).returns({})
15
+
16
+ RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
17
+
18
+ refund = Refund.new(@client, 1234)
19
+ refund = refund.create(456, {:amount => 800})
20
+
21
+ assert_instance_of(Invoiced::Refund, refund)
22
+ assert_equal(456, refund.id)
23
+ end
24
+ end
25
+ end
@@ -87,5 +87,18 @@ module Invoiced
87
87
  assert_true(subscription.cancel)
88
88
  assert_equal("canceled", subscription.status)
89
89
  end
90
+
91
+ should "preview a subscription" do
92
+ mockResponse = mock('RestClient::Response')
93
+ mockResponse.stubs(:code).returns(200)
94
+ mockResponse.stubs(:body).returns('{"first_invoice": {"id": false}, "mrr": 9}')
95
+ mockResponse.stubs(:headers).returns({})
96
+
97
+ RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
98
+
99
+ subscription = Subscription.new(@client, 123)
100
+ preview = subscription.preview(:customer => 1234, :plan => "enterprise")
101
+ assert_equal(preview[:first_invoice], {:id=>false})
102
+ end
90
103
  end
91
104
  end
@@ -0,0 +1,90 @@
1
+ require File.expand_path('../../test_helper', __FILE__)
2
+
3
+ module Invoiced
4
+ class TaskTest < Test::Unit::TestCase
5
+ should "return the api endpoint" do
6
+ task = Task.new(@client, "test")
7
+ assert_equal('/tasks/test', task.endpoint())
8
+ end
9
+
10
+ should "create a task" do
11
+ mockResponse = mock('RestClient::Response')
12
+ mockResponse.stubs(:code).returns(201)
13
+ mockResponse.stubs(:body).returns('{"id":"test","name":"Test Task"}')
14
+ mockResponse.stubs(:headers).returns({})
15
+
16
+ RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
17
+
18
+ task = @client.Task.create({:name => "Test Task"})
19
+
20
+ assert_instance_of(Invoiced::Task, task)
21
+ assert_equal("test", task.id)
22
+ assert_equal('Test Task', task.name)
23
+ end
24
+
25
+ should "retrieve a task" do
26
+ mockResponse = mock('RestClient::Response')
27
+ mockResponse.stubs(:code).returns(200)
28
+ mockResponse.stubs(:body).returns('{"id":"test","name":"Test Task"}')
29
+ mockResponse.stubs(:headers).returns({})
30
+
31
+ RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
32
+
33
+ task = @client.Task.retrieve("test")
34
+
35
+ assert_instance_of(Invoiced::Task, task)
36
+ assert_equal("test", task.id)
37
+ assert_equal('Test Task', task.name)
38
+ end
39
+
40
+ should "not update a task when no params" do
41
+ task = Task.new(@client, "test")
42
+ assert_false(task.save)
43
+ end
44
+
45
+ should "update a task" 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
+ task = Task.new(@client, "test")
54
+ task.name = "new contents"
55
+ assert_true(task.save)
56
+
57
+ assert_equal(task.name, 'new contents')
58
+ end
59
+
60
+ should "list all tasks" do
61
+ mockResponse = mock('RestClient::Response')
62
+ mockResponse.stubs(:code).returns(200)
63
+ mockResponse.stubs(:body).returns('[{"id":"test","name":"Test Task"}]')
64
+ mockResponse.stubs(:headers).returns(:x_total_count => 15, :link => '<https://api.invoiced.com/tasks?per_page=25&page=1>; rel="self", <https://api.invoiced.com/tasks?per_page=25&page=1>; rel="first", <https://api.invoiced.com/tasks?per_page=25&page=1>; rel="last"')
65
+
66
+ RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
67
+
68
+ tasks, metadata = @client.Task.list
69
+
70
+ assert_instance_of(Array, tasks)
71
+ assert_equal(1, tasks.length)
72
+ assert_equal("test", tasks[0].id)
73
+
74
+ assert_instance_of(Invoiced::List, metadata)
75
+ assert_equal(15, metadata.total_count)
76
+ end
77
+
78
+ should "delete a task" 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
+ task = Task.new(@client, "test")
87
+ assert_true(task.delete)
88
+ end
89
+ end
90
+ end
@@ -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
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: 0.14.0
4
+ version: 2.0.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: 2018-06-11 00:00:00.000000000 Z
11
+ date: 2020-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -53,8 +53,12 @@ files:
53
53
  - invoiced.gemspec
54
54
  - lib/invoiced.rb
55
55
  - lib/invoiced/attachment.rb
56
- - lib/invoiced/catalog_item.rb
56
+ - lib/invoiced/bank_account.rb
57
+ - lib/invoiced/card.rb
58
+ - lib/invoiced/charge.rb
57
59
  - lib/invoiced/contact.rb
60
+ - lib/invoiced/coupon.rb
61
+ - lib/invoiced/credit_balance_adjustment.rb
58
62
  - lib/invoiced/credit_note.rb
59
63
  - lib/invoiced/customer.rb
60
64
  - lib/invoiced/email.rb
@@ -68,21 +72,32 @@ files:
68
72
  - lib/invoiced/event.rb
69
73
  - lib/invoiced/file.rb
70
74
  - lib/invoiced/invoice.rb
75
+ - lib/invoiced/item.rb
76
+ - lib/invoiced/letter.rb
71
77
  - lib/invoiced/line_item.rb
72
78
  - lib/invoiced/list.rb
79
+ - lib/invoiced/note.rb
73
80
  - lib/invoiced/object.rb
74
81
  - lib/invoiced/operations/create.rb
75
82
  - lib/invoiced/operations/delete.rb
76
83
  - lib/invoiced/operations/list.rb
77
84
  - lib/invoiced/operations/update.rb
85
+ - lib/invoiced/payment.rb
78
86
  - lib/invoiced/payment_plan.rb
87
+ - lib/invoiced/payment_source.rb
88
+ - lib/invoiced/payment_source_object.rb
79
89
  - lib/invoiced/plan.rb
90
+ - lib/invoiced/refund.rb
80
91
  - lib/invoiced/subscription.rb
81
- - lib/invoiced/transaction.rb
92
+ - lib/invoiced/task.rb
93
+ - lib/invoiced/tax_rate.rb
94
+ - lib/invoiced/text_message.rb
82
95
  - lib/invoiced/util.rb
83
96
  - lib/invoiced/version.rb
84
- - test/invoiced/catalog_item_test.rb
97
+ - test/invoiced/charge_test.rb
85
98
  - test/invoiced/contact_test.rb
99
+ - test/invoiced/coupon_test.rb
100
+ - test/invoiced/credit_balance_adjustment.rb
86
101
  - test/invoiced/credit_note_test.rb
87
102
  - test/invoiced/customer_test.rb
88
103
  - test/invoiced/error_test.rb
@@ -91,12 +106,18 @@ files:
91
106
  - test/invoiced/file_test.rb
92
107
  - test/invoiced/invoice_test.rb
93
108
  - test/invoiced/invoiced_test.rb
109
+ - test/invoiced/item_test.rb
94
110
  - test/invoiced/line_item_test.rb
111
+ - test/invoiced/note_test.rb
95
112
  - test/invoiced/object_test.rb
96
113
  - test/invoiced/payment_plan_test.rb
114
+ - test/invoiced/payment_source_test.rb
115
+ - test/invoiced/payment_test.rb
97
116
  - test/invoiced/plan_test.rb
117
+ - test/invoiced/refund_test.rb
98
118
  - test/invoiced/subscription_test.rb
99
- - test/invoiced/transaction_test.rb
119
+ - test/invoiced/task_test.rb
120
+ - test/invoiced/tax_rate_test.rb
100
121
  - test/invoiced/util_test.rb
101
122
  - test/test_helper.rb
102
123
  homepage: https://invoiced.com/docs/dev
@@ -118,14 +139,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
139
  - !ruby/object:Gem::Version
119
140
  version: '0'
120
141
  requirements: []
121
- rubyforge_project:
122
- rubygems_version: 2.2.2
142
+ rubygems_version: 3.1.4
123
143
  signing_key:
124
144
  specification_version: 4
125
145
  summary: Ruby client library for the Invoiced API
126
146
  test_files:
127
- - test/invoiced/catalog_item_test.rb
147
+ - test/invoiced/charge_test.rb
128
148
  - test/invoiced/contact_test.rb
149
+ - test/invoiced/coupon_test.rb
150
+ - test/invoiced/credit_balance_adjustment.rb
129
151
  - test/invoiced/credit_note_test.rb
130
152
  - test/invoiced/customer_test.rb
131
153
  - test/invoiced/error_test.rb
@@ -134,11 +156,17 @@ test_files:
134
156
  - test/invoiced/file_test.rb
135
157
  - test/invoiced/invoice_test.rb
136
158
  - test/invoiced/invoiced_test.rb
159
+ - test/invoiced/item_test.rb
137
160
  - test/invoiced/line_item_test.rb
161
+ - test/invoiced/note_test.rb
138
162
  - test/invoiced/object_test.rb
139
163
  - test/invoiced/payment_plan_test.rb
164
+ - test/invoiced/payment_source_test.rb
165
+ - test/invoiced/payment_test.rb
140
166
  - test/invoiced/plan_test.rb
167
+ - test/invoiced/refund_test.rb
141
168
  - test/invoiced/subscription_test.rb
142
- - test/invoiced/transaction_test.rb
169
+ - test/invoiced/task_test.rb
170
+ - test/invoiced/tax_rate_test.rb
143
171
  - test/invoiced/util_test.rb
144
172
  - test/test_helper.rb