gotransverse-tract-api 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3a006a5aaaeae6a6d56f4ed22478c393c416cddd
4
- data.tar.gz: dd75eceecbea5cebc3e05b2f78c0b92c83203cf0
3
+ metadata.gz: 1340d5bebe6cca5359967a7b96282e234aa5ec03
4
+ data.tar.gz: 6d944de781f4a991719829fd87ace1de13fafc83
5
5
  SHA512:
6
- metadata.gz: d18ab13ad5bb93485dbc545d4f6fe6c29f6e229d74392e28183f278b4b1e5bcdac959d54ac5ff0d0da975855f69e389edc691d2320a6183322fc2ee42d292e9b
7
- data.tar.gz: f3964ace33739b0247208969bbcf2b7707fce8a4fa6b74d9a6a7c19b6cdfc287a6e904e44fec6d8118b4bf0c0f477de906c5199848afd39d667c330df23a4d66
6
+ metadata.gz: 08606f90f2de2b87b6d0bdee0c49e2710a58d42d87573d3d83340f27567fbb90ef8952bf662fbfcdfc73cebeb1a81996adbdf0e9343de6a7e755951218091710
7
+ data.tar.gz: f7a22b021f12a963c3f9f66a8f2e6fffb3b247888887f72e5ab33065a2829c3767a878b4c2499b23a649db96a69b5f6d372bed6121f6c70eef981b7b369bd001
@@ -48,6 +48,16 @@ require "gotransverse-tract-api/order/people"
48
48
  require "gotransverse-tract-api/order/product_relation"
49
49
  require "gotransverse-tract-api/order/renewal_order"
50
50
  require "gotransverse-tract-api/order/sales_order"
51
+ require "gotransverse-tract-api/order/agreement_configuration"
52
+ require "gotransverse-tract-api/order/discount_configuration"
53
+ require "gotransverse-tract-api/order/inventory_item"
54
+ require "gotransverse-tract-api/order/order_item_usage_rule"
55
+ require "gotransverse-tract-api/order/price_range"
56
+ require "gotransverse-tract-api/order/product_usage_rule"
57
+ require "gotransverse-tract-api/order/recurring_product_price"
58
+ require "gotransverse-tract-api/order/scheduled_charge"
59
+ require "gotransverse-tract-api/order/usage_rate"
60
+ require "gotransverse-tract-api/product/service_resource_category"
51
61
 
52
62
  require "gotransverse-tract-api/product/action"
53
63
  require "gotransverse-tract-api/product/discount_category"
@@ -239,7 +249,7 @@ module GoTransverseTractApi
239
249
  when :get
240
250
  response = http_client.get(api_url, api_params)
241
251
  when :post
242
- response = http_client.post(api_url, request_body, {'Content-Type' => 'application/xml'})
252
+ response = http_client.post(api_url, request_body, {'Content-Type' => 'application/xml', 'Accept' => 'application/xml'})
243
253
  when :put
244
254
  response = http_client.put(api_url, request_body, api_params)
245
255
  end
@@ -56,13 +56,8 @@ module GoTransverseTractApi
56
56
  orderStatus: sales_order[:order_status]
57
57
  },
58
58
  orderItems: {
59
- attributes: get_page_info(sales_order[:order_items]),
60
- order_item: {
61
- attributes: {
62
- quantity: sales_order[:order_items][:order_item][:quantity]
63
- },
64
- products: get_products(sales_order)
65
- }
59
+ attributes: {},
60
+ orderItem: Order::OrderItem.get_order_item(sales_order[:order_items][:order_item])
66
61
  },
67
62
  billingAccount: get_billing_account(sales_order[:billing_account])
68
63
  }
@@ -176,6 +171,14 @@ module GoTransverseTractApi
176
171
  end
177
172
 
178
173
  def get_billing_account(billing_account)
174
+ {
175
+ attributes: {
176
+ eid: billing_account[:eid]
177
+ }
178
+ }
179
+ end
180
+
181
+ def get_full_billing_account(billing_account)
179
182
  ba_details = {
180
183
  attributes: {
181
184
  accountNum: billing_account[:account_num],
@@ -187,7 +190,7 @@ module GoTransverseTractApi
187
190
  startDate: billing_account[:start_date],
188
191
  taxExempt: billing_account[:tax_exempt],
189
192
  eid: billing_account[:eid]
190
- },
193
+ }.delete_if{|k,v| v.nil?},
191
194
  dailyBillCycle: {
192
195
  name: billing_account[:daily_bill_cycle][:name],
193
196
  startDate: billing_account[:daily_bill_cycle][:start_date],
@@ -197,7 +200,7 @@ module GoTransverseTractApi
197
200
  usePaymentTerm: billing_account[:daily_bill_cycle][:use_payment_term],
198
201
  status: billing_account[:daily_bill_cycle][:status],
199
202
  eid: billing_account[:daily_bill_cycle][:eid]
200
- },
203
+ }.delete_if{|k,v| v.nil?},
201
204
  person: {
202
205
  attributes: {
203
206
  firstName: billing_account[:person][:first_name],
@@ -205,22 +208,22 @@ module GoTransverseTractApi
205
208
  eid: billing_account[:person][:eid]
206
209
  },
207
210
  addresses: get_addresses(billing_account[:person])
208
- },
211
+ }.delete_if{|k,v| v.nil?},
209
212
  billingAccountCategory: {
210
213
  type: billing_account[:billing_account_category][:type],
211
214
  description: billing_account[:billing_account_category][:description],
212
215
  status: billing_account[:billing_account_category][:status],
213
216
  eid: billing_account[:billing_account_category][:eid]
214
- },
217
+ }.delete_if{|k,v| v.nil?},
215
218
  paymentTerm: {
216
219
  name: billing_account[:payment_term][:name],
217
220
  termDays: billing_account[:payment_term][:term_days],
218
221
  graceDays: billing_account[:payment_term][:grace_days],
219
222
  eid: billing_account[:payment_term][:eid]
220
- }
223
+ }.delete_if{|k,v| v.nil?}
221
224
  }
222
225
 
223
- ba_details
226
+ ba_details.delete_if{|k,v| v.nil?}
224
227
  end
225
228
 
226
229
  def get_addresses(entity)
@@ -150,31 +150,32 @@ module GoTransverseTractApi
150
150
  def self.create_payment payment
151
151
  data = {
152
152
  payment: {
153
+ useRecurringPayment: payment[:use_recurring_payment],
153
154
  amount: payment[:amount],
154
155
  description: payment[:description]
155
156
  },
156
157
  billingAccount: {
157
- eid: payment[:billing_account][:eid]
158
+ eid: payment[:billing_account].try(:[],:eid)
158
159
  },
159
160
  creditCardPayment: {
160
- cardType: payment[:credit_card_payment][:card_type],
161
- cardHolderFirstName: payment[:credit_card_payment][:card_holder_first_name],
162
- cardHolderLastName: payment[:credit_card_payment][:card_holder_last_name],
163
- cardIdentifierNumber: payment[:credit_card_payment][:card_identifier_number],
164
- cardExpiration: payment[:credit_card_payment][:card_expiration]
165
- },
161
+ cardType: payment[:credit_card_payment].try(:[],:card_type),
162
+ cardHolderFirstName: payment[:credit_card_payment].try(:[],:card_holder_first_name),
163
+ cardHolderLastName: payment[:credit_card_payment].try(:[],:card_holder_last_name),
164
+ cardIdentifierNumber: payment[:credit_card_payment].try(:[],:card_identifier_number),
165
+ cardExpiration: payment[:credit_card_payment].try(:[],:card_expiration)
166
+ }.delete_if{|k,v| v.nil?},
166
167
  phoneNumber: {
167
- countryCode: payment[:phone_number][:country_code],
168
- areaCode: payment[:phone_number][:area_code],
169
- number: payment[:phone_number][:number],
170
- extension: payment[:phone_number][:extension],
171
- purpose: payment[:phone_number][:purpose]
172
- },
168
+ countryCode: payment[:phone_number].try(:[],:country_code),
169
+ areaCode: payment[:phone_number].try(:[],:area_code),
170
+ number: payment[:phone_number].try(:[],:number),
171
+ extension: payment[:phone_number].try(:[],:extension),
172
+ purpose: payment[:phone_number].try(:[],:purpose)
173
+ }.delete_if{|k,v| v.nil?},
173
174
  emailAddress: {
174
- email: payment[:email_address][:email],
175
- purpose: payment[:email_address][:purpose]
176
- }
177
- }
175
+ email: payment[:email_address].try(:[],:email),
176
+ purpose: payment[:email_address].try(:[],:purpose)
177
+ }.delete_if{|k,v| v.nil?}
178
+ }.delete_if{|k,v| v.empty?}
178
179
 
179
180
  xml_data = GoTransverseTractApi.generateXML(data, 'payment')
180
181
  GoTransverseTractApi.post_request_for(self, {}, xml_data, "")
@@ -21,7 +21,7 @@ module GoTransverseTractApi
21
21
  # @param {Long} account_num
22
22
  #
23
23
  def find_by_account_num account_num
24
- GoTransverseTractApi.get_response_for(self, {account_num: account_num})
24
+ GoTransverseTractApi.get_response_for(self, {account_num: account_num, query_scope: 'DEEP'})
25
25
  end
26
26
 
27
27
  #
@@ -65,6 +65,14 @@ module GoTransverseTractApi
65
65
  GoTransverseTractApi.get_response_for(self, {thru_date: thru_date})
66
66
  end
67
67
 
68
+ #
69
+ # @param {Hash} agreement
70
+ #
71
+ def get_selected_agreement agreement
72
+ {
73
+ eid: agreement[:eid]
74
+ }
75
+ end
68
76
  end
69
77
  end
70
78
 
@@ -0,0 +1,24 @@
1
+ module GoTransverseTractApi
2
+
3
+ module Order
4
+
5
+ class AgreementConfiguration
6
+
7
+ def self.get_agreement_conf agreement_conf
8
+ {
9
+ nextAgreement: agreement_conf[:next_agreement],
10
+ nextServiceProduct: agreement_conf[:next_service_product],
11
+ nextServiceProductPrice: agreement_conf[:next_service_product_price],
12
+ endDate: agreement_conf[:end_date],
13
+ endAction: agreement_conf[:end_action],
14
+ nextEndAction: agreement_conf[:next_end_action],
15
+ preserveServicePrice: agreement_conf[:preserve_service_price],
16
+ nextPreserveServicePrice: agreement_conf[:next_preserve_service_price]
17
+ }.delete_if{|k,v| v.nil?}
18
+ end
19
+
20
+ end
21
+
22
+ end
23
+
24
+ end
@@ -0,0 +1,28 @@
1
+ module GoTransverseTractApi
2
+
3
+ module Order
4
+
5
+ class DiscountConfiguration
6
+
7
+ def self.get_discount_configurations discount_configurations
8
+ disc_configurations = {
9
+ attributes: {},
10
+ discountConfiguration: {
11
+ attributes: {},
12
+ discountIdentifier: {
13
+ eid: discount_configurations[:discount_configuration][:discount_identifier][:eid]
14
+ }
15
+ }
16
+ }
17
+
18
+ disc_configurations
19
+ end
20
+
21
+ end
22
+
23
+ end
24
+
25
+ end
26
+ #overrideAmount: discount_configurations[:override_amount],
27
+ #overridePercentage: discount_configurations[:override_percentage],
28
+ #overrideDuration: discount_configurations[:override_duration]
@@ -0,0 +1,22 @@
1
+ module GoTransverseTractApi
2
+
3
+ module Order
4
+
5
+ class InventoryItem
6
+
7
+ class << self
8
+ def get_inventory_item inventory_item
9
+ {
10
+ eid: inventory_item[:eid],
11
+ product: inventory_item[:product],
12
+ serialNumber: inventory_item[:serial_number],
13
+ status: inventory_item[:status],
14
+ }
15
+ end
16
+ end
17
+
18
+ end
19
+
20
+ end
21
+
22
+ end
@@ -190,6 +190,49 @@ module GoTransverseTractApi
190
190
  GoTransverseTractApi.post_request_for(self, {eid: eid}, xml_data, "deny")
191
191
  end
192
192
 
193
+ #
194
+ # @param {Hash} order_item
195
+ #
196
+
197
+ def self.get_order_item(order_item)
198
+ if order_item.has_key?(:price_list)
199
+ price_list = Product::PriceList.get_price_list(order_item[:price_list])
200
+ end
201
+
202
+ if order_item.has_key?(:inventory_item)
203
+ inventory_item = InventoryItem.get_inventory_item(order_item[:inventory_item])
204
+ end
205
+
206
+ if order_item.has_key?(:scheduled_charges)
207
+ scheduled_charges = ScheduledCharge.get_scheduled_charges(order_item[:scheduled_charges])
208
+ end
209
+
210
+ orderItem = {
211
+ attributes: {
212
+ awaitingApproval: order_item[:awaiting_approval],
213
+ requestedEffectiveDate: order_item[:requested_effective_date],
214
+ unitPrice: order_item[:unit_price],
215
+ recurringUnitPrice: order_item[:recurring_unit_price],
216
+ quantity: order_item[:quantity],
217
+ sequence: order_item[:sequence],
218
+ description: order_item[:description],
219
+ eid: order_item[:eid]
220
+ }.delete_if{|k,v| v.nil?},
221
+ orderItemUsageRules: OrderItemUsageRule.get_order_item_usage_rule(order_item[:order_item_usage_rules]),
222
+ recurringProductPrice: RecurringProductPrice.get_recurring_product_price(order_item[:recurring_product_price]),
223
+ product: Product::Product.get_product_info(order_item[:product]),
224
+ priceList: price_list,
225
+ selectedAgreement: Agreement.get_selected_agreement(order_item[:selected_agreement]),
226
+ serviceResources: Service::ServiceResource.get_service_resource(order_item[:service_resources]),
227
+ inventoryItem: inventory_item,
228
+ agreementConfiguration: AgreementConfiguration.get_agreement_conf(order_item[:agreement_configuration]),
229
+ scheduledCharges: scheduled_charges,
230
+ discountConfigurations: DiscountConfiguration.get_discount_configurations(order_item[:discount_configurations])
231
+ }
232
+
233
+ orderItem.delete_if{|k,v| v.nil?}
234
+ end
235
+
193
236
  end
194
237
 
195
238
  end
@@ -0,0 +1,65 @@
1
+ module GoTransverseTractApi
2
+
3
+ module Order
4
+
5
+ class OrderItemUsageRule
6
+
7
+ class << self
8
+
9
+ #
10
+ # @param {Long} eid
11
+ #
12
+ def find_by_eid eid
13
+ GoTransverseTractApi.get_response_for(self, {eid: eid})
14
+ end
15
+
16
+ #
17
+ # @param {Long} order_item_eid
18
+ #
19
+ def find_by_order_item_eid order_item_eid
20
+ GoTransverseTractApi.get_response_for(self, {order_item_eid: order_item_eid})
21
+ end
22
+
23
+
24
+ def get_order_item_usage_rule(order_item_usage_rule)
25
+ if order_item_usage_rule.has_key?(:match_all_order_item_usage_rule)
26
+ if order_item_usage_rule[:match_all_order_item_usage_rule].has_key?(:usage_rate)
27
+ usage_rate = UsageRate.get_usage_rate(order_item_usage_rule[:match_all_order_item_usage_rule][:usage_rate])
28
+ end
29
+ end
30
+
31
+ order_item_usage_rules = {
32
+ attributes: {},
33
+ matchAllOrderItemUsageRule: {
34
+ attributes: {
35
+ eid: order_item_usage_rule[:match_all_order_item_usage_rule][:eid],
36
+ limit: order_item_usage_rule[:match_all_order_item_usage_rule][:limit],
37
+ usageUom: order_item_usage_rule[:match_all_order_item_usage_rule][:usage_uom],
38
+ name: order_item_usage_rule[:match_all_order_item_usage_rule][:name],
39
+ order: order_item_usage_rule[:match_all_order_item_usage_rule][:order],
40
+ proratedOnOrder: order_item_usage_rule[:match_all_order_item_usage_rule][:prorated_on_order],
41
+ proratedOnCancel: order_item_usage_rule[:match_all_order_item_usage_rule][:prorated_on_cancel],
42
+ rollOverType: order_item_usage_rule[:match_all_order_item_usage_rule][:roll_over_type],
43
+ allowanceType: order_item_usage_rule[:match_all_order_item_usage_rule][:allowance_type],
44
+ validFrom: order_item_usage_rule[:match_all_order_item_usage_rule][:valid_from],
45
+ validTo: order_item_usage_rule[:match_all_order_item_usage_rule][:valid_to],
46
+ ruleType: order_item_usage_rule[:match_all_order_item_usage_rule][:rule_type],
47
+ status: order_item_usage_rule[:match_all_order_item_usage_rule][:status],
48
+ chargeCategory: order_item_usage_rule[:match_all_order_item_usage_rule][:charge_category]
49
+ }.delete_if{|k,v| v.nil?},
50
+ matchAllProductUsageRule: {
51
+ eid: order_item_usage_rule[:match_all_order_item_usage_rule][:match_all_product_usage_rule][:eid]
52
+ },
53
+ usageRate: usage_rate
54
+ }
55
+ }
56
+
57
+ order_item_usage_rules.delete_if{|k,v| v.nil?}
58
+ end
59
+ end
60
+
61
+ end
62
+
63
+ end
64
+
65
+ end
@@ -0,0 +1,29 @@
1
+ module GoTransverseTractApi
2
+
3
+ module Order
4
+
5
+ class PriceRange
6
+
7
+ class << self
8
+ def get_price_ranges(price_ranges)
9
+ priceRanges = {
10
+ attributes: {},
11
+ priceRange: {
12
+ quantityBeginRange: price_ranges[:price_range][:quantity_begin_range],
13
+ quantityEndRange: price_ranges[:price_range][:quantity_end_range],
14
+ price: price_ranges[:price_range][:price],
15
+ level: price_ranges[:price_range][:level],
16
+ currencyType: price_ranges[:price_range][:currency_type],
17
+ eid: price_ranges[:price_range][:eid]
18
+ }
19
+ }
20
+
21
+ priceRanges
22
+ end
23
+ end
24
+
25
+ end
26
+
27
+ end
28
+
29
+ end
@@ -0,0 +1,40 @@
1
+ module GoTransverseTractApi
2
+
3
+ module Order
4
+
5
+ class ProductUsageRule
6
+
7
+ class << self
8
+ def get_product_usage_rules(product_usage_rules)
9
+ product_usage_rule = {
10
+ attributes: api_data.get_page_info(product_usage_rule),
11
+ matchAllProductUsageRule: {
12
+ attributes: {
13
+ eid: product_usage_rule[:eid],
14
+ limit: product_usage_rule[:limit],
15
+ usageUom: product_usage_rule[:usage_uom],
16
+ name: product_usage_rule[:name],
17
+ order: product_usage_rule[:order],
18
+ proratedOnOrder: product_usage_rule[:prorated_on_order],
19
+ proratedOnCancel: product_usage_rule[:prorated_on_cancel],
20
+ rollOverType: product_usage_rule[:roll_over_type],
21
+ allowanceType: product_usage_rule[:allowance_type],
22
+ validFrom: product_usage_rule[:valid_from],
23
+ validTo: product_usage_rule[:valid_to],
24
+ ruleType: product_usage_rule[:rule_type],
25
+ status: product_usage_rule[:status],
26
+ chargeCategory: product_usage_rule[:charge_category]
27
+ },
28
+ usageRate: UsageRate.get_usage_rate(product_usage_rule[:usage_rate])
29
+ }
30
+ }
31
+
32
+ product_usage_rule
33
+ end
34
+ end
35
+
36
+ end
37
+
38
+ end
39
+
40
+ end