gotransverse-tract-api 0.3.4 → 0.4.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 (31) hide show
  1. checksums.yaml +4 -4
  2. data/lib/gotransverse-tract-api.rb +51 -1
  3. data/lib/gotransverse-tract-api/api_data.rb +259 -0
  4. data/lib/gotransverse-tract-api/billing_account/adjustment.rb +205 -5
  5. data/lib/gotransverse-tract-api/billing_account/billing_account.rb +146 -13
  6. data/lib/gotransverse-tract-api/billing_account/invoice.rb +2 -1
  7. data/lib/gotransverse-tract-api/billing_account/payment.rb +90 -9
  8. data/lib/gotransverse-tract-api/billing_account/refund.rb +15 -1
  9. data/lib/gotransverse-tract-api/order/order_item.rb +179 -7
  10. data/lib/gotransverse-tract-api/order/organization.rb +15 -1
  11. data/lib/gotransverse-tract-api/order/people.rb +14 -16
  12. data/lib/gotransverse-tract-api/order/sales_order.rb +253 -6
  13. data/lib/gotransverse-tract-api/service/service.rb +273 -24
  14. data/lib/gotransverse-tract-api/service/service_resource.rb +65 -7
  15. data/lib/gotransverse-tract-api/usage/usage_event.rb +58 -3
  16. data/lib/gotransverse-tract-api/usage/usage_main.rb +19 -0
  17. data/lib/gotransverse-tract-api/usage/usage_some.rb +24 -0
  18. data/lib/gotransverse-tract-api/version.rb +1 -1
  19. data/spec/gotransverse-tract-api/billing_account/adjustment_spec.rb +190 -0
  20. data/spec/gotransverse-tract-api/billing_account/billing_account_spec.rb +380 -0
  21. data/spec/gotransverse-tract-api/billing_account/invoice_spec.rb +43 -0
  22. data/spec/gotransverse-tract-api/billing_account/payment_spec.rb +104 -2
  23. data/spec/gotransverse-tract-api/billing_account/refund_spec.rb +30 -0
  24. data/spec/gotransverse-tract-api/order/order_item_spec.rb +169 -0
  25. data/spec/gotransverse-tract-api/order/organization_spec.rb +32 -0
  26. data/spec/gotransverse-tract-api/order/people_spec.rb +32 -0
  27. data/spec/gotransverse-tract-api/order/sales_order_spec.rb +209 -0
  28. data/spec/gotransverse-tract-api/service/service_resource_spec.rb +83 -0
  29. data/spec/gotransverse-tract-api/service/service_spec.rb +194 -0
  30. data/spec/gotransverse-tract-api/usage/usage_event_spec.rb +57 -0
  31. metadata +27 -2
@@ -0,0 +1,83 @@
1
+ require 'spec_helper'
2
+ module GoTransverseTractApi
3
+
4
+ RSpec.describe Service::ServiceResource do
5
+ before(:each) { http_auth }
6
+
7
+ let(:response) { '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' }
8
+ let(:eid) { '48406' }
9
+ let(:root_attrs) {
10
+ {
11
+ :identifier => 'New id',
12
+ :status => 'AVAILABLE',
13
+ :description => 'Test'
14
+ }
15
+ }
16
+
17
+ context ".create_service_resource" do
18
+ it "creates a service resource" do
19
+ data = {
20
+ :category => {
21
+ eid: '324234'
22
+ }
23
+ }
24
+ allow(subject).to receive(:create_service_resource).with(eid, data).and_return(response)
25
+ expect(subject.create_service_resource(eid, data)).to eq(response)
26
+ end
27
+ end
28
+
29
+ context ".request" do
30
+ it "requests a service resource" do
31
+ data = {
32
+ :service_resource_category => {
33
+ eid: '324234'
34
+ }
35
+ }
36
+ #described_class.request(root_attrs.merge data)
37
+
38
+ allow(subject).to receive(:request).with(eid, data).and_return(response)
39
+ expect(subject.request(eid, data)).to eq(response)
40
+ end
41
+ end
42
+
43
+ context ".change" do
44
+ it "changes a service resource" do
45
+ data = {
46
+ :change_to_service_resource => root_attrs,
47
+ :category => { eid: '324234' }
48
+ }
49
+
50
+ allow(subject).to receive(:change).with(eid, data).and_return(response)
51
+ expect(subject.change(eid, data)).to eq(response)
52
+ end
53
+ end
54
+
55
+ context ".deactivate" do
56
+ it "deactivates a service resource" do
57
+ data = { }
58
+
59
+ allow(subject).to receive(:deactivate).with(eid, data).and_return(response)
60
+ expect(subject.deactivate(eid, data)).to eq(response)
61
+ end
62
+ end
63
+
64
+ context ".add_service_resource" do
65
+ it "adds a service resource" do
66
+ data = { }
67
+
68
+ allow(subject).to receive(:add_service_resource).with(eid, data).and_return(response)
69
+ expect(subject.add_service_resource(eid, data)).to eq(response)
70
+ end
71
+ end
72
+
73
+ context ".remove_service_resource" do
74
+ it "removes a service resource" do
75
+ data = { }
76
+
77
+ allow(subject).to receive(:remove_service_resource).with(eid, data).and_return(response)
78
+ expect(subject.remove_service_resource(eid, data)).to eq(response)
79
+ end
80
+ end
81
+
82
+ end
83
+ end
@@ -0,0 +1,194 @@
1
+ require 'spec_helper'
2
+
3
+ module GoTransverseTractApi
4
+
5
+ RSpec.describe Service::Service do
6
+ before(:each) { http_auth }
7
+
8
+ let(:response) { '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' }
9
+ let(:eid) { '48406' }
10
+
11
+ context ".renew" do
12
+ it "renews a service" do
13
+
14
+ data = {
15
+ eid: eid,
16
+ :billing_account => {
17
+ eid: '324234'
18
+ },
19
+ :order => {
20
+ :order_items => {
21
+ :order_item => {
22
+ :quantity => '1',
23
+ :sequence => '1',
24
+ :product => {
25
+ eid: '3453'
26
+ },
27
+ :selected_agreement => {
28
+ eid: '349'
29
+ }
30
+ }
31
+ },
32
+ :billing_account => {
33
+ eid: '324234'
34
+ },
35
+ :payments => {
36
+ :payment => {
37
+ :amount => '10.00',
38
+ :description => 'Testing',
39
+ :billing_account => {
40
+ eid: '324234'
41
+ },
42
+ :credit_card_payment => {
43
+ :card_type => 'VISA',
44
+ :card_holder_first_name => 'Mary',
45
+ :card_holder_middle_name => 'M',
46
+ :card_holder_last_name => 'Smith',
47
+ :card_identifier_number => '4111111111111111111',
48
+ :card_expiration => '12/2016'
49
+ }
50
+ },
51
+ }
52
+ }
53
+ }
54
+
55
+ allow(subject).to receive(:renew).with(eid, data).and_return(response)
56
+ expect(subject.renew(eid, data)).to eq(response)
57
+ end
58
+ end
59
+
60
+ context ".add_discount_identifier" do
61
+ it "adds a discount identifier" do
62
+
63
+ data = {
64
+ :amount => '10.00',
65
+ :start_date => '2015-01-01T10:10:10',
66
+ :status => 'ACTIVE',
67
+ :description => 'Testing',
68
+ :renewal_count => '0',
69
+ eid: eid,
70
+ :query_scope => 'SHALLOW',
71
+ :billing_account => {
72
+ eid: '324234',
73
+ :query_scope => 'EID',
74
+ },
75
+ :service_resources => {
76
+ :page_number => '1',
77
+ :page_size => '50',
78
+ :total_elements => '3',
79
+ :element_count => '0',
80
+ :total_pages => '0'
81
+ },
82
+ :product => {
83
+ eid: '608',
84
+ :query_scope => 'EID'
85
+ },
86
+ :service_periods => {
87
+ :page_number => '1',
88
+ :page_size => '50',
89
+ :total_elements => '3',
90
+ :element_count => '0',
91
+ :total_pages => '1'
92
+ },
93
+ :service_prices => {
94
+ :page_number => '1',
95
+ :page_size => '50',
96
+ :total_elements => '1',
97
+ :element_count => '0',
98
+ :total_pages => '1'
99
+ },
100
+ :service_usage_rules => {
101
+ :page_number => '1',
102
+ :page_size => '50',
103
+ :total_elements => '0',
104
+ :element_count => '0',
105
+ :total_pages => '0'
106
+ },
107
+ :counters => {
108
+ :page_number => '1',
109
+ :page_size => '50',
110
+ :total_elements => '1',
111
+ :element_count => '0',
112
+ :total_pages => '1'
113
+ },
114
+ :custom_field_values => {
115
+ :page_number => '1',
116
+ :page_size => '50',
117
+ :total_elements => '1',
118
+ :element_count => '0',
119
+ :total_pages => '1'
120
+ },
121
+ :discount_identifier => {
122
+ :status => 'ACTIVE',
123
+ :unlimited => 'true',
124
+ :uses => '12',
125
+ :identifier => 'dfsf',
126
+ eid: '23453',
127
+ :query_scope => 'DDGHJ',
128
+ :category => {
129
+ eid: '97',
130
+ :query_scope => 'EID'
131
+ }
132
+ }
133
+ }
134
+
135
+ allow(subject).to receive(:add_discount_identifier).with(eid, data).and_return(response)
136
+ expect(subject.add_discount_identifier(eid, data)).to eq(response)
137
+ end
138
+ end
139
+
140
+ context ".add_agreement" do
141
+ it "adds an agreement to the service" do
142
+ data = {
143
+ :service => {eid: eid},
144
+ :agreement_service => {
145
+ :end_action => 'RENEW_SERVICE',
146
+ :end_date => '2015-11-11T11:00:00',
147
+ :start_date => '2015-01-11T11:00:00',
148
+ :agreement => {eid: '123'}
149
+ }
150
+ }
151
+
152
+ allow(subject).to receive(:add_agreement).with(eid, data).and_return(response)
153
+ expect(subject.add_agreement(eid, data)).to eq(response)
154
+ end
155
+ end
156
+
157
+ context ".resume" do
158
+ it "resumes the service" do
159
+ data = { }
160
+
161
+ allow(subject).to receive(:resume).with(eid, data).and_return(response)
162
+ expect(subject.resume(eid, data)).to eq(response)
163
+ end
164
+ end
165
+
166
+ context ".suspend" do
167
+ it "suspends the service" do
168
+ data = { }
169
+
170
+ allow(subject).to receive(:suspend).with(eid, data).and_return(response)
171
+ expect(subject.suspend(eid, data)).to eq(response)
172
+ end
173
+ end
174
+
175
+ context ".add_service_usage_rule_to_service" do
176
+ it "adds a service usage rule to the service" do
177
+ data = { }
178
+
179
+ allow(subject).to receive(:add_service_usage_rule_to_service).with(eid, data).and_return(response)
180
+ expect(subject.add_service_usage_rule_to_service(eid, data)).to eq(response)
181
+ end
182
+ end
183
+
184
+ context ".remove_service_usage_rule_from_service" do
185
+ it "removes a service usage rule from the service" do
186
+ data = { }
187
+
188
+ allow(subject).to receive(:remove_service_usage_rule_from_service).with(eid, data).and_return(response)
189
+ expect(subject.remove_service_usage_rule_from_service(eid, data)).to eq(response)
190
+ end
191
+ end
192
+
193
+ end
194
+ end
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ module GoTransverseTractApi
4
+
5
+ RSpec.describe Usage::UsageEvent do
6
+ before(:each) { http_auth }
7
+
8
+ let(:response) { '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' }
9
+ let(:event) {
10
+ {
11
+ :start_time => '20151125T10:10:10',
12
+ :service_resource_id => 'Remax',
13
+ :usage_uom => 'EVENT',
14
+ :usage_amount => '1200.00',
15
+ :description => 'Testing',
16
+ :service_resource_type => 'GENERICSVC'
17
+ }
18
+ }
19
+
20
+ context ".create_usage_event" do
21
+ it "creates a usage event" do
22
+ elem = { :number01 => '90' }
23
+
24
+ data = event.delete_if do|k,v|
25
+ k.to_s == 'description'
26
+ end
27
+
28
+ #described_class.create_usage_event(data.merge!(elem))
29
+
30
+ allow(subject).to receive(:create_usage_event).with(data).and_return(response)
31
+ expect(subject.create_usage_event(data)).to eq(response)
32
+ end
33
+ end
34
+
35
+ context ".void_event" do
36
+ it "voids a single usage event" do
37
+ data = { eid: '3166788' }
38
+
39
+ allow(subject).to receive(:void_event).with(data).and_return(response)
40
+ expect(subject.void_event(data)).to eq(response)
41
+ end
42
+ end
43
+
44
+ context ".bulk" do
45
+ it "creates multiple usage events in bulk" do
46
+ events = []
47
+
48
+ (0..2).each{ |i| events[i] = event }
49
+
50
+ allow(subject).to receive(:bulk).with(events).and_return(response)
51
+ expect(subject.bulk(events)).to eq(response)
52
+ end
53
+ end
54
+
55
+ end
56
+ end
57
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gotransverse-tract-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julien DeFrance
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-12-01 00:00:00.000000000 Z
12
+ date: 2015-12-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -118,6 +118,7 @@ files:
118
118
  - Rakefile
119
119
  - gotransverse-tract-api.gemspec
120
120
  - lib/gotransverse-tract-api.rb
121
+ - lib/gotransverse-tract-api/api_data.rb
121
122
  - lib/gotransverse-tract-api/billing_account/adjustment.rb
122
123
  - lib/gotransverse-tract-api/billing_account/adjustment_application.rb
123
124
  - lib/gotransverse-tract-api/billing_account/adjustment_reason.rb
@@ -195,12 +196,25 @@ files:
195
196
  - lib/gotransverse-tract-api/usage/usage_event.rb
196
197
  - lib/gotransverse-tract-api/usage/usage_lookup_table.rb
197
198
  - lib/gotransverse-tract-api/usage/usage_lookup_table_entry.rb
199
+ - lib/gotransverse-tract-api/usage/usage_main.rb
198
200
  - lib/gotransverse-tract-api/usage/usage_price_category.rb
199
201
  - lib/gotransverse-tract-api/usage/usage_rule.rb
202
+ - lib/gotransverse-tract-api/usage/usage_some.rb
200
203
  - lib/gotransverse-tract-api/version.rb
201
204
  - spec/auth_helper.rb
205
+ - spec/gotransverse-tract-api/billing_account/adjustment_spec.rb
206
+ - spec/gotransverse-tract-api/billing_account/billing_account_spec.rb
207
+ - spec/gotransverse-tract-api/billing_account/invoice_spec.rb
202
208
  - spec/gotransverse-tract-api/billing_account/payment_spec.rb
209
+ - spec/gotransverse-tract-api/billing_account/refund_spec.rb
210
+ - spec/gotransverse-tract-api/order/order_item_spec.rb
211
+ - spec/gotransverse-tract-api/order/organization_spec.rb
212
+ - spec/gotransverse-tract-api/order/people_spec.rb
213
+ - spec/gotransverse-tract-api/order/sales_order_spec.rb
203
214
  - spec/gotransverse-tract-api/product/product_spec.rb
215
+ - spec/gotransverse-tract-api/service/service_resource_spec.rb
216
+ - spec/gotransverse-tract-api/service/service_spec.rb
217
+ - spec/gotransverse-tract-api/usage/usage_event_spec.rb
204
218
  - spec/spec_helper.rb
205
219
  homepage: https://rubygems.org/gems/gotransverse-tract-api
206
220
  licenses:
@@ -229,6 +243,17 @@ summary: A ruby gem allowing developers to conveniently integrate with GoTransve
229
243
  TRACT API.
230
244
  test_files:
231
245
  - spec/auth_helper.rb
246
+ - spec/gotransverse-tract-api/billing_account/adjustment_spec.rb
247
+ - spec/gotransverse-tract-api/billing_account/billing_account_spec.rb
248
+ - spec/gotransverse-tract-api/billing_account/invoice_spec.rb
232
249
  - spec/gotransverse-tract-api/billing_account/payment_spec.rb
250
+ - spec/gotransverse-tract-api/billing_account/refund_spec.rb
251
+ - spec/gotransverse-tract-api/order/order_item_spec.rb
252
+ - spec/gotransverse-tract-api/order/organization_spec.rb
253
+ - spec/gotransverse-tract-api/order/people_spec.rb
254
+ - spec/gotransverse-tract-api/order/sales_order_spec.rb
233
255
  - spec/gotransverse-tract-api/product/product_spec.rb
256
+ - spec/gotransverse-tract-api/service/service_resource_spec.rb
257
+ - spec/gotransverse-tract-api/service/service_spec.rb
258
+ - spec/gotransverse-tract-api/usage/usage_event_spec.rb
234
259
  - spec/spec_helper.rb