gotransverse-tract-api 0.5.0 → 0.5.1

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 +11 -1
  3. data/lib/gotransverse-tract-api/api_data.rb +16 -13
  4. data/lib/gotransverse-tract-api/billing_account/payment.rb +18 -17
  5. data/lib/gotransverse-tract-api/billing_account/recurring_payment.rb +1 -1
  6. data/lib/gotransverse-tract-api/order/agreement.rb +8 -0
  7. data/lib/gotransverse-tract-api/order/agreement_configuration.rb +24 -0
  8. data/lib/gotransverse-tract-api/order/discount_configuration.rb +28 -0
  9. data/lib/gotransverse-tract-api/order/inventory_item.rb +22 -0
  10. data/lib/gotransverse-tract-api/order/order_item.rb +43 -0
  11. data/lib/gotransverse-tract-api/order/order_item_usage_rule.rb +65 -0
  12. data/lib/gotransverse-tract-api/order/price_range.rb +29 -0
  13. data/lib/gotransverse-tract-api/order/product_usage_rule.rb +40 -0
  14. data/lib/gotransverse-tract-api/order/recurring_product_price.rb +48 -0
  15. data/lib/gotransverse-tract-api/order/sales_order.rb +3 -39
  16. data/lib/gotransverse-tract-api/order/scheduled_charge.rb +26 -0
  17. data/lib/gotransverse-tract-api/order/usage_rate.rb +31 -0
  18. data/lib/gotransverse-tract-api/product/discount_category.rb +1 -1
  19. data/lib/gotransverse-tract-api/product/price_list.rb +10 -1
  20. data/lib/gotransverse-tract-api/product/product.rb +46 -0
  21. data/lib/gotransverse-tract-api/product/product_category.rb +9 -0
  22. data/lib/gotransverse-tract-api/product/service_resource_category.rb +20 -0
  23. data/lib/gotransverse-tract-api/service/service_resource.rb +29 -3
  24. data/lib/gotransverse-tract-api/version.rb +1 -1
  25. data/spec/gotransverse-tract-api/billing_account/billing_account_spec.rb +49 -138
  26. data/spec/gotransverse-tract-api/billing_account/payment_spec.rb +26 -25
  27. data/spec/gotransverse-tract-api/billing_account/recurring_payment_spec.rb +16 -0
  28. data/spec/gotransverse-tract-api/order/order_item_usage_rule_spec.rb +24 -0
  29. data/spec/gotransverse-tract-api/order/sales_order_spec.rb +4 -106
  30. data/spec/gotransverse-tract-api/service/service_resource_spec.rb +7 -0
  31. metadata +16 -2
@@ -0,0 +1,48 @@
1
+ module GoTransverseTractApi
2
+
3
+ module Order
4
+
5
+ class RecurringProductPrice
6
+
7
+ class << self
8
+ def get_recurring_product_price(recurring_product_price)
9
+ if recurring_product_price.has_key?('price_ranges')
10
+ price_ranges = PriceRange.get_price_ranges(recurring_product_price[:price_ranges])
11
+ end
12
+
13
+ if recurring_product_price.has_key?('product_usage_rules')
14
+ product_usage_rules = ProductUsageRule.get_product_usage_rule(recurring_product_price[:product_usage_rules])
15
+ end
16
+
17
+ recurringProductPrice = {
18
+ attributes: {
19
+ fromDate: recurring_product_price[:from_date],
20
+ priceOverride: recurring_product_price[:price_override],
21
+ type: recurring_product_price[:type],
22
+ paymentOnPurchaseRequired: recurring_product_price[:payment_on_purchase_required],
23
+ recurringPaymentRequired: recurring_product_price[:recurring_payment_required],
24
+ recurrencePeriod: recurring_product_price[:recurrence_period],
25
+ recurrenceAmount: recurring_product_price[:recurrence_amount],
26
+ allowScheduledCharges: recurring_product_price[:allow_scheduled_charges],
27
+ currencyType: recurring_product_price[:currency_type],
28
+ proratedOnOrder: recurring_product_price[:prorated_on_order],
29
+ proratedOnCancel: recurring_product_price[:prorated_on_cancel],
30
+ proratedOnOrderNoCharge: recurring_product_price[:prorated_on_order_no_charge],
31
+ billInAdvance: recurring_product_price[:bill_in_advance],
32
+ eid: recurring_product_price[:eid]
33
+ }.delete_if{|k,v| v.nil?},
34
+ priceRanges: price_ranges,
35
+ productUsageRules: product_usage_rules
36
+ }
37
+
38
+ recurringProductPrice.delete_if{|k,v| v.nil?}
39
+ end
40
+ end
41
+
42
+ end
43
+
44
+ end
45
+
46
+ end
47
+
48
+
@@ -102,52 +102,16 @@ module GoTransverseTractApi
102
102
  # @param {Long} eid
103
103
  # @param {Hash} sales_order
104
104
  #
105
- def confirm eid, sales_order
106
- payment = sales_order[:payment]
107
- sales_order = sales_order[:sales_order]
108
-
109
- order_item_struct = prepare_products_struct(sales_order)
110
-
105
+ def confirm eid
111
106
  data = {
112
107
  confirmOrder: {},
113
108
  salesOrder: {
114
- attributes: {
115
- referral: sales_order[:referral],
116
- orderDate: sales_order[:order_date],
117
- orderStatus: sales_order[:order_status],
118
- eid: eid
119
- },
120
- orderItems: {
121
- attributes: GoTransverseTractApi::ApiData.new.get_page_info(sales_order[:order_items]),
122
- orderItem: order_item_struct
123
- },
124
- billingAccount: {
125
- automaticRecurringPayment: sales_order[:billing_account][:automatic_recurring_payment],
126
- eid: sales_order[:billing_account][:eid]
127
- }
128
- },
129
- payment: {
130
- attributes: {
131
- amount: payment[:amount],
132
- description: payment[:description]
133
- },
134
- billingAccount: {
135
- automaticRecurringPayment: payment[:billing_account][:automatic_recurring_payment],
136
- eid: payment[:billing_account][:eid]
137
- },
138
- creditCardPayment: {
139
- cardType: payment[:credit_card_payment][:card_type],
140
- cardHolderFirstName: payment[:credit_card_payment][:card_holder_first_name],
141
- cardHolderMiddleName: payment[:credit_card_payment][:card_holder_middle_name],
142
- cardHolderLastName: payment[:credit_card_payment][:card_holder_last_name],
143
- cardIdentifierNumber: payment[:credit_card_payment][:card_identifier_number],
144
- cardExpiration: payment[:credit_card_payment][:card_expiration]
145
- }
109
+ attributes: { eid: eid },
110
+ orderItems: {},
146
111
  }
147
112
  }
148
113
 
149
114
  xml_data = GoTransverseTractApi.generateXML(data, 'confirmOrder')
150
-
151
115
  GoTransverseTractApi.post_request_for(self, {eid: eid}, xml_data, 'confirm')
152
116
  end
153
117
 
@@ -0,0 +1,26 @@
1
+ module GoTransverseTractApi
2
+
3
+ module Order
4
+
5
+ class ScheduledCharge
6
+
7
+ def self.get_scheduled_charges scheduled_charges
8
+ sch_charges = {
9
+ attributes: api_data.get_page_info(scheduled_charges),
10
+ scheduleCharge: {
11
+ eid: scheduled_charges[:eid],
12
+ description: scheduled_charges[:description],
13
+ amount: scheduled_charges[:amount],
14
+ invoiced: scheduled_charges[:invoiced],
15
+ chargeDate: scheduled_charges[:charge_date]
16
+ }
17
+ }
18
+
19
+ sch_charges.delete_if{|k,v| v.nil?}
20
+ end
21
+
22
+ end
23
+
24
+ end
25
+
26
+ end
@@ -0,0 +1,31 @@
1
+ module GoTransverseTractApi
2
+
3
+ module Order
4
+
5
+ class UsageRate
6
+
7
+ class << self
8
+ def get_usage_rate(usage_rate)
9
+ usage_rates = {
10
+ attributes: {},
11
+ flatUsageRate: {
12
+ attributes: {
13
+ eid: usage_rate[:flat_usage_rate][:eid],
14
+ uom: usage_rate[:flat_usage_rate][:uom],
15
+ validFrom: usage_rate[:flat_usage_rate][:valid_from],
16
+ validTo: usage_rate[:flat_usage_rate][:valid_to],
17
+ rate: usage_rate[:flat_usage_rate][:rate]
18
+ }.delete_if{|k,v| v.nil?}
19
+ }
20
+ }
21
+
22
+ usage_rates
23
+ end
24
+ end
25
+
26
+ end
27
+
28
+ end
29
+
30
+ end
31
+
@@ -25,7 +25,7 @@ module GoTransverseTractApi
25
25
  #
26
26
  # @param {String} status
27
27
  #
28
- def find_by_status status
28
+ def self.find_by_status status
29
29
  GoTransverseTractApi.get_response_for(self, {status: status})
30
30
  end
31
31
 
@@ -22,8 +22,17 @@ module GoTransverseTractApi
22
22
  GoTransverseTractApi.get_response_for(self, {name: name})
23
23
  end
24
24
 
25
+ #
26
+ # @param {Hash} price_list
27
+ #
28
+ def self.get_price_list price_list
29
+ {
30
+ name: price_list[:name],
31
+ eid: price_list[:eid]
32
+ }
33
+ end
25
34
  end
26
35
 
27
36
  end
28
37
 
29
- end
38
+ end
@@ -115,6 +115,52 @@ module GoTransverseTractApi
115
115
  GoTransverseTractApi.get_response_for(self, {product_tag_eid: product_tag_eid})
116
116
  end
117
117
 
118
+ #
119
+ # @param {Hash} product
120
+ #
121
+ def get_product_info product
122
+ if product.has_key?(:product_prices)
123
+ product_prices = Order::RecurringProductPrice.get_recurring_product_price(product[:product_prices])
124
+ end
125
+
126
+ if product.has_key?(:product_category)
127
+ product_category = ProductCategory.get_product_category(product[:product_category])
128
+ end
129
+
130
+ if product.has_key?(:service_resource_category)
131
+ svc_resource_category = ServiceResourceCategory.get_service_resource_category(product[:service_resource_category])
132
+ end
133
+
134
+ if product.has_key?(:product_usage_rules)
135
+ product_usage_rules = Order::ProductUsageRule.get_product_usage_rule(product[:product_usage_rules])
136
+ end
137
+
138
+ product_info = {
139
+ attributes: {
140
+ name: product[:name],
141
+ description: product[:description],
142
+ shortDescription: product[:short_description],
143
+ productTypeCode: product[:product_type_code],
144
+ productState: product[:product_state],
145
+ requiresAgreement: product[:requires_agreement],
146
+ serialized: product[:serialized],
147
+ taxable: product[:taxable],
148
+ trial: product[:trial],
149
+ defaultQuantity: product[:default_quantity],
150
+ internalName: product[:internal_name],
151
+ minServiceResources: product[:min_service_resources],
152
+ maxServiceResources: product[:max_service_resources],
153
+ trialOverride: product[:trial_override],
154
+ eid: product[:eid]
155
+ }.delete_if{|k,v| v.nil?},
156
+ productPrices: product_prices,
157
+ productCategory: product_category,
158
+ serviceResourceCategory: svc_resource_category,
159
+ productUsageRules: product_usage_rules
160
+ }
161
+
162
+ product_info.delete_if{|k,v| v.nil?}
163
+ end
118
164
  end
119
165
 
120
166
  end
@@ -3,7 +3,16 @@ module GoTransverseTractApi
3
3
  module Product
4
4
 
5
5
  class ProductCategory < DiscountCategory
6
+ def self.get_product_category(product_category)
7
+ product_category = {
8
+ name: product_category[:name],
9
+ description: product_category[:description],
10
+ status: product_category[:status],
11
+ eid: product_category[:eid]
12
+ }
6
13
 
14
+ product_category
15
+ end
7
16
  end
8
17
 
9
18
  end
@@ -0,0 +1,20 @@
1
+ module GoTransverseTractApi
2
+
3
+ module Product
4
+
5
+ class ServiceResourceCategory
6
+ def self.get_service_resource_category(service_resource_category)
7
+ service_resource_category = {
8
+ name: service_resource_category[:name],
9
+ type: service_resource_category[:type],
10
+ status: service_resource_category[:status],
11
+ eid: service_resource_category[:eid]
12
+ }
13
+
14
+ service_resource_category
15
+ end
16
+ end
17
+
18
+ end
19
+
20
+ end
@@ -9,7 +9,7 @@ module GoTransverseTractApi
9
9
  #
10
10
  # @param {Long} eid
11
11
  #
12
- def self.find_by_eid eid
12
+ def find_by_eid eid
13
13
  GoTransverseTractApi.get_response_for(self, {eid: eid})
14
14
  end
15
15
 
@@ -37,7 +37,7 @@ module GoTransverseTractApi
37
37
  #
38
38
  # @param {Long} identifier
39
39
  #
40
- def self.find_by_identifier identifier
40
+ def find_by_identifier identifier
41
41
  GoTransverseTractApi.get_response_for(self, {identifier: identifier})
42
42
  end
43
43
 
@@ -165,7 +165,7 @@ module GoTransverseTractApi
165
165
  # @param {Long} eid
166
166
  # @param {Hash} service_resource
167
167
  #
168
- def self.remove_service_resource eid, service_resource
168
+ def remove_service_resource eid, service_resource
169
169
  data = {
170
170
  removeServiceResourceFromService: {},
171
171
  service: {eid: eid},
@@ -176,6 +176,32 @@ module GoTransverseTractApi
176
176
  GoTransverseTractApi.post_request_for(self, {eid: eid}, xml_data, "removeServiceResource")
177
177
  end
178
178
 
179
+ #
180
+ # @param {Hash} service_resource
181
+ #
182
+ def get_service_resource service_resources
183
+ svc_resource = service_resources[:service_resource]
184
+ service_resource = {
185
+ attributes: {},
186
+ serviceResource: {
187
+ attributes: {
188
+ eid: svc_resource[:eid],
189
+ identifier: svc_resource[:identifier],
190
+ description: svc_resource[:description],
191
+ autoSelect: svc_resource[:autoSelect],
192
+ status: svc_resource[:status]
193
+ }.delete_if{|k,v| v.nil?},
194
+ category: {
195
+ eid: svc_resource[:category].try(:[],:eid),
196
+ name: svc_resource[:category].try(:[],:name),
197
+ type: svc_resource[:category].try(:[],:type),
198
+ status: svc_resource[:category].try(:[],:status)
199
+ }.delete_if{|k,v| v.nil?}
200
+ }
201
+ }
202
+
203
+ service_resource
204
+ end
179
205
  end
180
206
 
181
207
  end
@@ -1,6 +1,6 @@
1
1
  module GoTransverseTractApi
2
2
 
3
- VERSION = "0.5.0"
3
+ VERSION = "0.5.1"
4
4
  TARGET_API_VERSION = "1.28"
5
5
 
6
6
  end
@@ -6,7 +6,7 @@ module GoTransverseTractApi
6
6
  before(:each) { http_auth }
7
7
 
8
8
  let(:response) { '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' }
9
- let(:eid) { '48406' }
9
+ let(:eid) { '136' }
10
10
  let(:addresses) { {
11
11
  :email_address => {
12
12
  :purpose => 'PRIMARY',
@@ -228,150 +228,61 @@ module GoTransverseTractApi
228
228
 
229
229
  context ".create_draft_order" do
230
230
  it "creates a draft sales order for the billing account" do
231
-
232
231
  data = {
233
- :sales_order => {
234
- :referral => 'Unit Test Referral',
235
- :order_date => '2015-07-09T17:22:13',
236
- :order_status => 'DRAFT',
237
- :order_items => {
238
- :page_number => '1',
239
- :page_size => '50',
240
- :total_elements => '0',
241
- :element_count => '0',
242
- :total_pages => '0',
243
- :order_item => {
244
- :quantity => '1',
245
- :products => [{
246
- :name => 'Simple Subscription',
247
- :description => 'dsfsgegebdbb',
248
- :short_description => 'asfgerdbdb',
249
- :product_type_code => 'SUBSCRIPTION',
250
- :product_state => 'PRODUCT_AVAILABLE',
251
- :requires_agreement => 'false',
252
- :serialized => 'true',
253
- :taxable => 'false',
254
- :trial => 'false',
255
- :default_quantity => '1',
256
- :min_service_resources => '0',
257
- :max_service_resources => '0',
258
- :trial_override => 'false',
259
- :eid => '51',
260
- :product_prices => {
261
- :page_number => '1',
262
- :page_size => '50',
263
- :total_elements => '2',
264
- :element_count => '2',
265
- :total_pages => '1',
266
- :productprices => [{
267
- :from_date => '2013-02-10T01:00:00',
268
- :price_override => 'true',
269
- :type => 'OneTime',
270
- :recurring_payment_required => 'false',
271
- :eid => '82',
272
- :price_ranges => {
273
- :page_number => '1',
274
- :page_size => '50',
275
- :total_elements => '1',
276
- :element_count => '1',
277
- :total_pages => '1',
278
- :priceranges => [{
279
- :quantity_begin_range => '0.00',
280
- :price => '100.00',
281
- :level => '1',
282
- :eid => '103'
283
- }]
232
+ sales_order: {
233
+ referral: 'Unit Test Referral',
234
+ order_date: '2015-07-09T17:22:13',
235
+ order_status: 'DRAFT',
236
+ order_items: {
237
+ order_item: {
238
+ recurring_unit_price: '100.00',
239
+ quantity: '1',
240
+ sequence: '1',
241
+ description: 'dsfsgegebdbb',
242
+ product: { eid: '67' },
243
+ selected_agreement: { eid: '15' },
244
+ recurring_product_price: { eid: '102' },
245
+ order_item_usage_rules: {
246
+ match_all_order_item_usage_rule: {
247
+ name: 'allowance',
248
+ status: 'ACTIVE',
249
+ allowance_type: 'One Time',
250
+ limit: '500',
251
+ usage_uom: 'COUNT',
252
+ charge_category: '34',
253
+ match_all_product_usage_rule: { eid: '22' },
254
+ usage_rate: {
255
+ flat_usage_rate: {
256
+ rate: '2.00',
257
+ uom: 'COUNT'
284
258
  }
285
- },
286
- {
287
- :from_date => '2013-12-10T01:00:00',
288
- :price_override => 'true',
289
- :type => 'Recurring',
290
- :recurring_payment_required => 'false',
291
- :eid => '82',
292
- :price_ranges => {
293
- :page_number => '1',
294
- :page_size => '50',
295
- :total_elements => '1',
296
- :element_count => '1',
297
- :total_pages => '1',
298
- :priceranges => [{
299
- :quantity_begin_range => '0.00',
300
- :price => '10.00',
301
- :level => '1',
302
- :eid => '103'
303
- }]
304
- }
305
- }]
306
- },
307
- :product_category => {
308
- :name => 'Default',
309
- :description => 'Default Product Category',
310
- :status => 'ACTIVE',
311
- :eid => '8'
312
- },
313
- :actions => {
314
- :page_number => '1',
315
- :page_size => '50',
316
- :total_elements => '1',
317
- :element_count => '1',
318
- :total_pages => '1'
319
- },
320
- :product_usage_rules => {
321
- :page_number => '1',
322
- :page_size => '50',
323
- :total_elements => '1',
324
- :element_count => '1',
325
- :total_pages => '1'
259
+ }
326
260
  }
327
- }]
261
+ },
262
+ agreement_configuration: {
263
+ end_date: '01012016',
264
+ end_action: 'RENEW_AGREEMENT',
265
+ preserve_service_price: '1',
266
+ next_preserve_service_price: '0'
267
+ },
268
+ service_resources: {
269
+ service_resource: {
270
+ identifier: 'rg36',
271
+ category: { eid: '9' }
272
+ }
273
+ },
274
+ discount_configurations: {
275
+ discount_configuration: {
276
+ discount_identifier: { eid: '35' }
277
+ }
278
+ }
328
279
  }
329
280
  },
330
- :billing_account => {
331
- :account_num => '8',
332
- :bill_type => 'EMAIL',
333
- :automatic_recurring_payment => 'false',
334
- :status => 'ACTIVE',
335
- :pending_charges_total => '0.00',
336
- :balance => '-10.00',
337
- :start_date => '2014-11-11T10:00:00',
338
- :tax_exempt => 'false',
339
- :eid => '29',
340
- :daily_bill_cycle => {
341
- :name => 'daily 10 to 3',
342
- :start_date => '2014-11-11T10:00:00',
343
- :end_date => '2014-11-12T10:00:00',
344
- :bill_cycle_type => 'Daily',
345
- :auto_bill => 'true',
346
- :status => 'ACTIVE',
347
- :eid => '25'
348
- },
349
- :person => {
350
- :first_name => 'John',
351
- :last_name => 'Smith',
352
- :middle_name => 'S',
353
- :eid => '133',
354
- :addresses => addresses
355
- },
356
- :billing_account_category => {
357
- :type => 'All Accounts',
358
- :description => 'Default billing account category',
359
- :status => 'BA_CATEGORY_ACTIVE',
360
- :eid => '6'
361
- },
362
- :payment_term => {
363
- :name => 'Immediate',
364
- :term_days => '0',
365
- :grace_days => '0',
366
- :eid => '8'
367
- }
368
- }
281
+ billing_account: { eid: eid }
369
282
  }
370
283
  }
371
-
372
- data[:sales_order][:billing_account][:person][:addresses][:email_address][:eid] = '123'
373
- data[:sales_order][:billing_account][:person][:addresses][:postal_address][:eid] = '345'
374
- data[:sales_order][:billing_account][:person][:addresses][:telecom_address][:eid] = '678'
284
+
285
+ #res = described_class.create_draft_order(eid, data)
375
286
 
376
287
  allow(subject).to receive(:create_draft_order).with(eid, data).and_return(response)
377
288
  expect(subject.create_draft_order(eid, data)).to eq(response)