gotransverse-tract-api 0.3.4 → 0.4.0

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 +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
@@ -59,7 +59,16 @@ module GoTransverseTractApi
59
59
  # @param {Hash} service_resource
60
60
  #
61
61
  def request service_resource
62
- GoTransverseTractApi.post_request_for(self, {}, service_resource, "request")
62
+ data = {
63
+ :requestServiceResource => {
64
+ :identifier => service_resource[:identifier],
65
+ :status => service_resource[:status],
66
+ :description => service_resource[:description]
67
+ },
68
+ :serviceResourceCategory => {eid: service_resource[:service_resource_category][:eid]}
69
+ }
70
+ xml_data = GoTransverseTractApi.generateXML(data, 'requestServiceResource')
71
+ GoTransverseTractApi.post_request_for(self, {}, xml_data, "request")
63
72
  end
64
73
 
65
74
  #
@@ -67,7 +76,21 @@ module GoTransverseTractApi
67
76
  # @param {Hash} service_resource
68
77
  #
69
78
  def change eid, service_resource
70
- GoTransverseTractApi.post_request_for(self, {eid: eid}, service_resource, "change")
79
+ data = {
80
+ :changeServiceResource => {},
81
+ :serviceResource => {eid: eid},
82
+ :changeToServiceResource => {
83
+ :attributes => {
84
+ :identifier => service_resource[:change_to_service_resource][:identifier],
85
+ :status => service_resource[:change_to_service_resource][:status],
86
+ :description => service_resource[:change_to_service_resource][:description]
87
+ },
88
+ :category => {eid: service_resource[:category][:eid]}
89
+ }
90
+ }
91
+
92
+ xml_data = GoTransverseTractApi.generateXML(data, 'changeServiceResource')
93
+ GoTransverseTractApi.post_request_for(self, {eid: eid}, xml_data, "change")
71
94
  end
72
95
 
73
96
  #
@@ -75,14 +98,30 @@ module GoTransverseTractApi
75
98
  # @param {Hash} service_resource
76
99
  #
77
100
  def deactivate eid, service_resource
78
- GoTransverseTractApi.post_request_for(self, {eid: eid}, service_resource, "deactivate")
101
+ data = {
102
+ :deactivateServiceResource => {},
103
+ :serviceResource => {eid: eid}
104
+ }
105
+
106
+ xml_data = GoTransverseTractApi.generateXML(data, 'deactivateServiceResource')
107
+ GoTransverseTractApi.post_request_for(self, {eid: eid}, xml_data, "deactivate")
79
108
  end
80
109
 
81
110
  #
82
111
  # @param {Hash} service_resource
83
112
  #
84
113
  def create_service_resource service_resource
85
- GoTransverseTractApi.post_request_for(self, {}, service_resource, "")
114
+ data = {
115
+ :serviceResource => {
116
+ :identifier => service_resource[:identifier],
117
+ :status => service_resource[:status],
118
+ :description => service_resource[:description]
119
+ },
120
+ :category => {eid: service_resource[:category][:eid]}
121
+ }
122
+
123
+ xml_data = GoTransverseTractApi.generateXML(data, 'serviceResource')
124
+ GoTransverseTractApi.post_request_for(self, {}, xml_data, "")
86
125
  end
87
126
 
88
127
  #
@@ -97,8 +136,20 @@ module GoTransverseTractApi
97
136
  # @param {Long} eid
98
137
  # @param {Hash} service_resource
99
138
  #
100
- def self.add_service_resource eid, service_resource
101
- GoTransverseTractApi.post_request_for(self, {eid: eid}, service_resource, "addServiceResource")
139
+ def add_service_resource eid, service_resource
140
+ data = {
141
+ :addServiceResourceToService => {},
142
+ :service => {eid: eid},
143
+ :serviceResource => {
144
+ :attributes => {
145
+ :identifier => service_resource[:identifier]
146
+ },
147
+ :category => {eid: service_resource[:category][:eid]}
148
+ }
149
+ }
150
+
151
+ xml_data = GoTransverseTractApi.generateXML(data, 'addServiceResourceToService')
152
+ GoTransverseTractApi.post_request_for(self, {eid: eid}, xml_data, "addServiceResource")
102
153
  end
103
154
 
104
155
  #
@@ -106,7 +157,14 @@ module GoTransverseTractApi
106
157
  # @param {Hash} service_resource
107
158
  #
108
159
  def self.remove_service_resource eid, service_resource
109
- GoTransverseTractApi.post_request_for(self, {eid: eid}, service_resource, "removeServiceResource")
160
+ data = {
161
+ :removeServiceResourceFromService => {},
162
+ :service => {eid: eid},
163
+ :serviceResource => {eid: service_resource[:eid]}
164
+ }
165
+
166
+ xml_data = GoTransverseTractApi.generateXML(data, 'removeServiceResourceFromService')
167
+ GoTransverseTractApi.post_request_for(self, {eid: eid}, xml_data, "removeServiceResource")
110
168
  end
111
169
 
112
170
  end
@@ -69,21 +69,76 @@ module GoTransverseTractApi
69
69
  # @param {Hash} usage_event
70
70
  #
71
71
  def create_usage_event usage_event
72
- GoTransverseTractApi.post_request_for(self, {}, usage_event, "")
72
+ data = {
73
+ usageEvent: {
74
+ startTime: usage_event[:start_time],
75
+ serviceResourceId: usage_event[:service_resource_id],
76
+ usageUom: usage_event[:usage_uom],
77
+ usageAmount: usage_event[:usage_amount],
78
+ number01: usage_event[:number01]
79
+ },
80
+ serviceResourceType: usage_event[:service_resource_type]
81
+ }
82
+
83
+ xml_data = GoTransverseTractApi.generateXML(data, 'usageEvent')
84
+ GoTransverseTractApi.post_request_for(self, xml_data, "")
73
85
  end
74
86
 
75
87
  #
76
88
  # @param {Hash} usage_event
77
89
  #
78
90
  def bulk usage_event
79
- GoTransverseTractApi.post_request_for(self, {}, usage_event, "bulk")
91
+ data = {
92
+ bulkUsageEvents: {},
93
+ usageEvents: get_usage_events(usage_event)
94
+ }
95
+
96
+ xml_data = GoTransverseTractApi.generateXML(data, 'bulkUsageEvents')
97
+ GoTransverseTractApi.post_request_for(self, {}, xml_data, "bulk")
80
98
  end
81
99
 
82
100
  #
83
101
  # @param {Hash} usage_event
84
102
  #
85
103
  def void_event usage_event
86
- GoTransverseTractApi.post_request_for(self, {}, usage_event, "void_event")
104
+
105
+ data = {
106
+ voidUsageEvent: {},
107
+ usageEvent: {
108
+ eid: usage_event[:eid]
109
+ }
110
+ }
111
+
112
+ xml_data = GoTransverseTractApi.generateXML(data, 'voidUsageEvent')
113
+ GoTransverseTractApi.post_request_for(self, usage_event, "void_event")
114
+ end
115
+
116
+ private
117
+
118
+ #
119
+ # params: [Array] Usage Events
120
+ #
121
+ # Returns [Array] of usage events for XML
122
+ #
123
+ def get_usage_events(usage_event)
124
+ events = []
125
+
126
+ usage_event.each do|event|
127
+ events << {
128
+ usageEvent: {
129
+ attributes: {
130
+ startTime: event[:start_time],
131
+ serviceResourceId: event[:service_resource_id],
132
+ usageUom: event[:usage_uom],
133
+ usageAmount: event[:usage_amount],
134
+ description: event[:description]
135
+ },
136
+ serviceResourceType: event[:service_resource_type]
137
+ }
138
+ }
139
+ end
140
+
141
+ events
87
142
  end
88
143
 
89
144
  end
@@ -0,0 +1,19 @@
1
+ module GoTransverseTractApi
2
+
3
+ module UsageMain
4
+
5
+ class << self
6
+
7
+ #
8
+ # @param {Long} eid
9
+ #
10
+ def find_by_eid eid
11
+ debugger
12
+ GoTransverseTractApi.get_response_for(self, {eid: eid})
13
+ end
14
+
15
+ end
16
+
17
+ end
18
+
19
+ end
@@ -0,0 +1,24 @@
1
+ module GoTransverseTractApi
2
+
3
+ module Usage
4
+
5
+ class UsageSome
6
+ include UsageMain
7
+
8
+ class << self
9
+
10
+ #
11
+ # @param {Long} billing_account_eid
12
+ # @param {Boolean} closed
13
+ #
14
+ def find_by_billing_account_eid billing_account_eid, closed
15
+ GoTransverseTractApi.get_response_for(self, {billing_account_eid: billing_account_eid, closed: closed})
16
+ end
17
+
18
+ end
19
+
20
+ end
21
+
22
+ end
23
+
24
+ end
@@ -1,6 +1,6 @@
1
1
  module GoTransverseTractApi
2
2
 
3
- VERSION = "0.3.4"
3
+ VERSION = "0.4.0"
4
4
  TARGET_API_VERSION = "1.28"
5
5
 
6
6
  end
@@ -0,0 +1,190 @@
1
+ require 'spec_helper'
2
+
3
+ module GoTransverseTractApi
4
+
5
+ RSpec.describe BillingAccount::Adjustment do
6
+ before(:each) { http_auth }
7
+
8
+ let(:response) { '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' }
9
+ let(:eid) { '48406' }
10
+ let(:data) { {
11
+ :full_amount => 'true',
12
+ :occurred_on => '2014-10-01T00:00:00',
13
+ :amount => '1.00',
14
+ :description => 'dsfsfsdfsdfsd sdsdsdvss',
15
+ :invoiced => 'false',
16
+ :credit => 'true',
17
+ :status => 'pending',
18
+ :type => 'MANUAL',
19
+ :manual_invoice_application => 'true',
20
+ eid: '124343',
21
+ :billing_account => {
22
+ :account_num => '5635',
23
+ :bill_type => 'EMAIL',
24
+ :automatic_recurring_payment => 'false',
25
+ :status => 'Active',
26
+ :pending_charges_total => '0.00',
27
+ :balance => '-10.00',
28
+ :start_date => '2014-11-11T10:00:00',
29
+ :tax_exempt => 'false',
30
+ eid: '3663',
31
+ :daily_bill_cycle => {
32
+ :name => 'daily 10 to 3',
33
+ :start_date => '2014-11-11T10:00:00',
34
+ :end_date => '2014-11-12T10:00:00',
35
+ :bill_cycle_type => 'Daily',
36
+ :auto_bill => 'true',
37
+ :use_payment_term => 'true',
38
+ :status => 'ACTIVE',
39
+ eid: '223'
40
+ },
41
+ :person => {
42
+ :first_name => 'John',
43
+ :last_name => 'Smith',
44
+ eid: '3305',
45
+ :addresses => {
46
+ :postal_address => {
47
+ :purpose => 'BILLING',
48
+ :country => 'USA',
49
+ :city => 'Dallas',
50
+ :region_or_state => 'TX',
51
+ :postal_code => '78665',
52
+ :line1 => '123 Main St',
53
+ eid: '3453'
54
+ },
55
+ :email_address => {
56
+ :purpose => 'PRIMARY',
57
+ :email => 'john@smith.com',
58
+ eid: '3453'
59
+ }
60
+ }
61
+ },
62
+ :billing_account_category => {
63
+ :type => 'All',
64
+ :description => 'dsdgdg dhretsdfdg eggdg',
65
+ :status => 'ACTIVE',
66
+ eid: '45354'
67
+ },
68
+ :services => {
69
+ :page_number => '1',
70
+ :page_size => '50',
71
+ :total_elements => '1',
72
+ :element_count => '0',
73
+ :total_pages => '1'
74
+ },
75
+ :payment_term => {
76
+ :name => 'Immediate',
77
+ :term_days => '0',
78
+ :grace_days => '0',
79
+ eid: '353'
80
+ }
81
+ },
82
+ :reason => {
83
+ :name => 'Default Credit Adjustment',
84
+ :description => 'sefwgsvd dhgrgsfree ergreg',
85
+ :status => 'Active',
86
+ :credit_only => 'true',
87
+ eid: '99'
88
+ }
89
+ } }
90
+
91
+ context ".post" do
92
+ it "posts the adjustment" do
93
+ data_for_post = {
94
+ eid: '124343'
95
+ }
96
+
97
+ allow(subject).to receive(:post).with(eid, data_for_post).and_return(response)
98
+ expect(subject.post(eid, data_for_post)).to eq(response)
99
+ end
100
+ end
101
+
102
+ context ".reverse" do
103
+ it "reverses the adjustment" do
104
+ allow(subject).to receive(:reverse).with(eid, data).and_return(response)
105
+ expect(subject.reverse(eid, data)).to eq(response)
106
+ end
107
+ end
108
+
109
+ context ".add_invoice_application" do
110
+ it "adds invoice application to adjustment" do
111
+ data[:invoice_adjustment_application] = {
112
+ :amount => '1.0',
113
+ :invoice => {
114
+ :invoice_num => '23',
115
+ :amount => '10.00',
116
+ :pdf_path => 'https://my.tractbilling.com/t/s/r/1.28/invoices/2914/pdf',
117
+ :occurred_on => '2014-10-10T00:00:00',
118
+ :due_date => '2014-10-10T00:00:00',
119
+ :amount_to_pay => '4.00',
120
+ :late_fee_charged => 'false',
121
+ :status => 'open',
122
+ :usage_csv_path => 'https://my.tractbilling.com/t/s/r/1.28/invoices/2914/csv',
123
+ eid: '2342'
124
+ }
125
+ }
126
+
127
+ allow(subject).to receive(:add_invoice_application).with(eid, data).and_return(response)
128
+ expect(subject.add_invoice_application(eid, data)).to eq(response)
129
+ end
130
+ end
131
+
132
+ context ".reverse_invoice_application" do
133
+ it "reverses invoice application from adjustment" do
134
+
135
+ data[:invoice_adjustment_application] = {
136
+ :reversed => 'false',
137
+ :applied_on => '2014-10-10T10:10:10',
138
+ :amount => '1.0',
139
+ eid: '197',
140
+ :account_adjustment => {
141
+ :invoiced => 'true',
142
+ :credit => 'true',
143
+ :status => 'POSTED',
144
+ :posted_on => '2014-01-01T10:00:00',
145
+ :posted_by => 'Admin'
146
+ },
147
+ :invoice => {
148
+ :invoice_num => '23',
149
+ :amount => '10.00',
150
+ :pdf_path => 'https://my.tractbilling.com/t/s/r/1.28/invoices/2914/pdf',
151
+ :occurred_on => '2014-10-10T00:00:00',
152
+ :due_date => '2014-10-10T00:00:00',
153
+ :amount_to_pay => '4.00',
154
+ :late_fee_charged => 'false',
155
+ :status => 'open',
156
+ :usage_csv_path => 'https://my.tractbilling.com/t/s/r/1.28/invoices/2914/csv',
157
+ eid: '2342'
158
+ }
159
+ }
160
+
161
+ allow(subject).to receive(:reverse_invoice_application).with(eid, data).and_return(response)
162
+ expect(subject.reverse_invoice_application(eid, data)).to eq(response)
163
+ end
164
+ end
165
+
166
+ context ".create_adjustment" do
167
+ it "creates an adjustment" do
168
+ data = {
169
+ :occurred_on => '2013-11-11T11:00:00',
170
+ :amount => '10.00',
171
+ :description => 'some thing fishy',
172
+ :type => 'MANUAL',
173
+ :credit => 'true',
174
+ :posted => 'false',
175
+ :billing_account => {
176
+ eid: '322'
177
+ },
178
+ :reason => {
179
+ eid: '6456'
180
+ }
181
+ }
182
+
183
+ allow(subject).to receive(:create_adjustment).with(data).and_return(response)
184
+ expect(subject.create_adjustment(data)).to eq(response)
185
+ end
186
+ end
187
+
188
+ end
189
+ end
190
+
@@ -0,0 +1,380 @@
1
+ require 'spec_helper'
2
+
3
+ module GoTransverseTractApi
4
+
5
+ RSpec.describe BillingAccount::BillingAccount do
6
+ before(:each) { http_auth }
7
+
8
+ let(:response) { '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' }
9
+ let(:eid) { '48406' }
10
+ let(:addresses) { {
11
+ :email_address => {
12
+ :purpose => 'primary',
13
+ :email => 'test@test.com'
14
+ },
15
+ :postal_address => {
16
+ :purpose => 'BILLING',
17
+ :country => 'USA',
18
+ :city => 'Pleasanton',
19
+ :region_or_state => 'CA',
20
+ :attention => 'John Simth',
21
+ :postal_code => '94588',
22
+ :line1 => '3423 something st.'
23
+ },
24
+ :telecom_address => {
25
+ :purpose => 'OFFICE',
26
+ :dialing_prefix => '9',
27
+ :country_code => '1',
28
+ :area_code => '925',
29
+ :number => '2341212',
30
+ :extension => '21'
31
+ }
32
+ } }
33
+
34
+
35
+ context ".apply_payment" do
36
+ it "applies a payment to the invoice" do
37
+ data = {
38
+ :billing_account => {
39
+ eid: '123'
40
+ },
41
+ :invoice => {
42
+ eid: '456'
43
+ },
44
+ :payment => {
45
+ :amount => '27',
46
+ :use_recurring_payment => 'false',
47
+ :credit_card_payment => {
48
+ :card_type => 'VISA',
49
+ :card_holder_first_name => 'Mary',
50
+ :card_holder_last_name => 'Smith',
51
+ :card_identifier_number => '4111111111111111111',
52
+ :card_verification_number => '123',
53
+ :card_expiration => '12/2016',
54
+ :description => 'Test Desc'
55
+ },
56
+ :billing_account => {
57
+ eid: '123'
58
+ }
59
+ }
60
+ }
61
+
62
+ allow(subject).to receive(:apply_payment).with(eid, data).and_return(response)
63
+ expect(subject.apply_payment(eid, data)).to eq(response)
64
+ end
65
+ end
66
+
67
+ context ".suspend" do
68
+ it "suspends a billing account" do
69
+ data = {
70
+ :billing_account => {
71
+ eid: '123'
72
+ },
73
+ :reason => {
74
+ eid: '456'
75
+ }
76
+ }
77
+
78
+ allow(subject).to receive(:suspend).with(eid, data).and_return(response)
79
+ expect(subject.suspend(eid, data)).to eq(response)
80
+ end
81
+ end
82
+
83
+ context ".resume" do
84
+ it "resumes a billing account" do
85
+ data = {
86
+ :billing_account => {eid: eid},
87
+ :start_date => '2014-11-11T10:00:00',
88
+ :notes => 'Test notes here'
89
+ }
90
+
91
+ allow(subject).to receive(:resume).with(eid, data).and_return(response)
92
+ expect(subject.resume(eid, data)).to eq(response)
93
+ end
94
+ end
95
+
96
+ context ".add_recurring_payment" do
97
+ it "adds a recurring payment to the billing account" do
98
+ data = {
99
+ :billing_account => {eid: eid},
100
+ :recurring_payment => {
101
+ :credit_card_payment_method => {
102
+ :card_type => 'VISA',
103
+ :card_holder_first_name => 'Mary',
104
+ :card_holder_last_name => 'Smith',
105
+ :card_identifier_number => '4111111111111111111',
106
+ :card_expiration => '12/2016'
107
+ }
108
+ }
109
+ }
110
+
111
+ allow(subject).to receive(:add_recurring_payment).with(eid, data).and_return(response)
112
+ expect(subject.add_recurring_payment(eid, data)).to eq(response)
113
+ end
114
+ end
115
+
116
+ context ".change_service" do
117
+ it "changes service on a billing account" do
118
+ data = {
119
+ :service => {eid: '136'},
120
+ :order => {
121
+ :note => 'Simple note',
122
+ :order_items => {
123
+ :order_item => {
124
+ :quantity => 2,
125
+ :description => 'change service',
126
+ :products => [{
127
+ eid: '1234'
128
+ },
129
+ {
130
+ eid: '4567'
131
+ }]
132
+ }
133
+ },
134
+ :billing_account => {eid: eid}
135
+ }
136
+ }
137
+
138
+ allow(subject).to receive(:change_service).with(eid, data).and_return(response)
139
+ expect(subject.change_service(eid, data)).to eq(response)
140
+ end
141
+ end
142
+
143
+ context ".add_custom_field_value" do
144
+ it "adds custom field value to the billing account" do
145
+ data = {
146
+ :billing_account => { eid: eid },
147
+ :custom_field_value => { :value => 'yes' }
148
+ }
149
+
150
+ allow(subject).to receive(:add_custom_field_value).with(eid, data).and_return(response)
151
+ expect(subject.add_custom_field_value(eid, data)).to eq(response)
152
+ end
153
+ end
154
+
155
+ context ".remove_custom_field_value" do
156
+ it "removes custom field value from the billing account" do
157
+ data = {
158
+ :billing_account => { eid: eid },
159
+ :custom_field_value => { eid: '486' }
160
+ }
161
+
162
+ allow(subject).to receive(:remove_custom_field_value).with(eid, data).and_return(response)
163
+ expect(subject.remove_custom_field_value(eid, data)).to eq(response)
164
+ end
165
+ end
166
+
167
+ context ".deactivate" do
168
+ it "deactivates a billing account" do
169
+ data = {
170
+ :billing_account => { eid: '123' },
171
+ :reason => { eid: '456' }
172
+ }
173
+
174
+ allow(subject).to receive(:deactivate).with(eid, data).and_return(response)
175
+ expect(subject.deactivate(eid, data)).to eq(response)
176
+ end
177
+ end
178
+
179
+ context ".create_billing_account" do
180
+ it "creates a billing account" do
181
+ data = {
182
+ :bill_type => 'EMAIL',
183
+ :daily_bill_cycle => { eid: '123' },
184
+ :organization => {
185
+ :name => 'test services',
186
+ :addresses => addresses
187
+ },
188
+ :billing_account_category => {
189
+ eid: '123'
190
+ }
191
+ }
192
+
193
+ allow(subject).to receive(:create_billing_account).with(data).and_return(response)
194
+ expect(subject.create_billing_account(data)).to eq(response)
195
+ end
196
+ end
197
+
198
+ context ".add_person" do
199
+ it "adds a person to the billing account" do
200
+ data = {
201
+ :billing_account => { eid: eid },
202
+ :person => {
203
+ :first_name => 'Tim',
204
+ :last_name => 'John',
205
+ :middle_name => 'R',
206
+ :addresses => addresses
207
+ }
208
+ }
209
+
210
+ allow(subject).to receive(:add_person).with(eid, data).and_return(response)
211
+ expect(subject.add_person(eid, data)).to eq(response)
212
+ end
213
+ end
214
+
215
+ context ".remove_billing_account" do
216
+ it "removes a person from the billing account" do
217
+ data = {
218
+ :billing_account => { eid: eid },
219
+ :person => { eid: '123' }
220
+ }
221
+
222
+ allow(subject).to receive(:remove_billing_account).with(eid, data).and_return(response)
223
+ expect(subject.remove_billing_account(eid, data)).to eq(response)
224
+ end
225
+ end
226
+
227
+ context ".create_draft_order" do
228
+ it "creates a draft sales order for the billing account" do
229
+
230
+ data = {
231
+ :sales_order => {
232
+ :referral => 'Order Item',
233
+ :order_date => '2015-07-09',
234
+ :order_status => 'DRAFT',
235
+ :order_items => {
236
+ :page_number => '1',
237
+ :page_size => '50',
238
+ :total_elements => '0',
239
+ :element_count => '0',
240
+ :total_pages => '0',
241
+ :order_item => {
242
+ :quantity => '1',
243
+ :products => [{
244
+ :name => 'sdfsdfsvs',
245
+ :description => 'dsfsgegebdbb',
246
+ :short_description => 'asfgerdbdb',
247
+ :product_type_code => 'udygciww',
248
+ :product_state => 'afwfwss',
249
+ :requires_agreement => 'true',
250
+ :serialized => 'false',
251
+ :taxable => 'false',
252
+ :trial => 'asda',
253
+ :default_quantity => '10',
254
+ :min_service_resources => '0',
255
+ :max_service_resources => '0',
256
+ :trial_override => 'false',
257
+ eid: '234',
258
+ :product_prices => {
259
+ :page_number => '1',
260
+ :page_size => '50',
261
+ :total_elements => '2',
262
+ :element_count => '2',
263
+ :total_pages => '1',
264
+ :productprices => [{
265
+ :from_date => '2013-02-10T01:00:00',
266
+ :price_override => 'true',
267
+ :type => 'OneTime',
268
+ :recurring_payment_required => 'false',
269
+ eid: '12345',
270
+ :price_ranges => {
271
+ :page_number => '1',
272
+ :page_size => '50',
273
+ :total_elements => '1',
274
+ :element_count => '1',
275
+ :total_pages => '1',
276
+ :priceranges => [{
277
+ :quantity_begin_range => '0.00',
278
+ :price => '100.00',
279
+ :level => '1',
280
+ eid: '781'
281
+ }]
282
+ }
283
+ },
284
+ {
285
+ :from_date => '2013-12-10T01:00:00',
286
+ :price_override => 'true',
287
+ :type => 'Recurring',
288
+ :recurring_payment_required => 'false',
289
+ eid: '348',
290
+ :price_ranges => {
291
+ :page_number => '1',
292
+ :page_size => '50',
293
+ :total_elements => '1',
294
+ :element_count => '1',
295
+ :total_pages => '1',
296
+ :priceranges => [{
297
+ :quantity_begin_range => '0.00',
298
+ :price => '10.00',
299
+ :level => '1',
300
+ eid: '812'
301
+ }]
302
+ }
303
+ }]
304
+ },
305
+ :product_category => {
306
+ :name => 'sdfsdfs',
307
+ :description => 'wrggdgd',
308
+ :status => 'Active',
309
+ eid: '234'
310
+ },
311
+ :actions => {
312
+ :page_number => '1',
313
+ :page_size => '50',
314
+ :total_elements => '1',
315
+ :element_count => '1',
316
+ :total_pages => '1'
317
+ },
318
+ :product_usage_rules => {
319
+ :page_number => '1',
320
+ :page_size => '50',
321
+ :total_elements => '1',
322
+ :element_count => '1',
323
+ :total_pages => '1'
324
+ }
325
+ }]
326
+ }
327
+ },
328
+ :billing_account => {
329
+ :account_num => '5635',
330
+ :bill_type => 'EMAIL',
331
+ :automatic_recurring_payment => 'false',
332
+ :status => 'Active',
333
+ :pending_charges_total => '0.00',
334
+ :balance => '-10.00',
335
+ :start_date => '2014-11-11T10:00:00',
336
+ :tax_exempt => 'false',
337
+ eid: '3663',
338
+ :daily_bill_cycle => {
339
+ :name => 'daily 10 to 3',
340
+ :start_date => '2014-11-11T10:00:00',
341
+ :end_date => '2014-11-12T10:00:00',
342
+ :bill_cycle_type => 'Daily',
343
+ :auto_bill => 'true',
344
+ :status => 'ACTIVE',
345
+ eid: '223'
346
+ },
347
+ :person => {
348
+ :first_name => 'John',
349
+ :last_name => 'Smith',
350
+ :middle_name => 'S',
351
+ eid: '3305',
352
+ :addresses => addresses
353
+ },
354
+ :billing_account_category => {
355
+ :type => 'All',
356
+ :description => 'dsdgdg dhretsdfdg eggdg',
357
+ :status => 'ACTIVE',
358
+ eid: '45354'
359
+ },
360
+ :payment_term => {
361
+ :name => 'Immediate',
362
+ :term_days => '0',
363
+ :grace_days => '0',
364
+ eid: '353'
365
+ }
366
+ }
367
+ }
368
+ }
369
+
370
+ data[:sales_order][:billing_account][:person][:addresses][:email_address][:eid] = '123'
371
+ data[:sales_order][:billing_account][:person][:addresses][:postal_address][:eid] = '345'
372
+ data[:sales_order][:billing_account][:person][:addresses][:telecom_address][:eid] = '678'
373
+
374
+ allow(subject).to receive(:create_draft_order).with(eid, data).and_return(response)
375
+ expect(subject.create_draft_order(eid, data)).to eq(response)
376
+ end
377
+ end
378
+
379
+ end
380
+ end