Skip to content

Commit ba283d3

Browse files
author
Shairyar Baig
authored
Merge pull request #1190 from travis-ci/epic_maint
Billing maintenance milestone 1
2 parents 5fba5a4 + aac4c20 commit ba283d3

File tree

9 files changed

+33
-9
lines changed

9 files changed

+33
-9
lines changed

lib/travis/api/v3/models/v2_subscription.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def initialize(attributes = {})
2424
end
2525

2626
class Models::V2BillingInfo
27-
attr_reader :id, :address, :address2, :billing_email, :city, :company, :country, :first_name, :last_name, :state, :vat_id, :zip_code
27+
attr_reader :id, :address, :address2, :billing_email, :city, :company, :country, :first_name, :last_name, :state, :vat_id, :zip_code, :has_local_registration
2828

2929
def initialize(id, attrs)
3030
@id = id
@@ -39,6 +39,7 @@ def initialize(id, attrs)
3939
@state = attrs.fetch('state')
4040
@vat_id = attrs.fetch('vat_id')
4141
@zip_code = attrs.fetch('zip_code')
42+
@has_local_registration = attrs.fetch('has_local_registration', false)
4243
end
4344
end
4445

lib/travis/api/v3/queries/v2_subscriptions.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Travis::API::V3
22
class Queries::V2Subscriptions < Query
33
params :plan, :coupon, :organization_id, :client_secret, :v1_subscription_id
4-
params :first_name, :last_name, :company, :address, :address2, :city, :country, :state, :vat_id, :zip_code, :billing_email, prefix: :billing_info
4+
params :first_name, :last_name, :company, :address, :address2, :city, :country, :state, :vat_id, :zip_code, :billing_email, :has_local_registration, prefix: :billing_info
55
params :token, prefix: :credit_card_info
66

77
def all(user_id)

lib/travis/api/v3/renderer/v2_subscription.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def payment_intent
2020
end
2121

2222
class Renderer::V2BillingInfo < ModelRenderer
23-
representation(:standard, :id, :address, :address2, :billing_email, :city, :company, :country, :first_name, :last_name, :state, :vat_id, :zip_code)
23+
representation(:standard, :id, :address, :address2, :billing_email, :city, :company, :country, :first_name, :last_name, :state, :vat_id, :zip_code, :has_local_registration)
2424
end
2525

2626
class Renderer::V2CreditCardInfo < ModelRenderer

lib/travis/api/v3/services/v2_subscription/update_address.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Travis::API::V3
22
class Services::V2Subscription::UpdateAddress < Service
3-
params :first_name, :last_name, :company, :address, :address2, :city, :country, :state, :vat_id, :zip_code, :billing_email
3+
params :first_name, :last_name, :company, :address, :address2, :city, :country, :state, :vat_id, :zip_code, :billing_email, :has_local_registration
44

55
def run!
66
raise LoginRequired unless access_control.full_access_or_logged_in?

lib/travis/api/v3/services/v2_subscriptions/create.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module Travis::API::V3
22
class Services::V2Subscriptions::Create < Service
33
result_type :v2_subscription
44
params :plan, :coupon, :organization_id, :client_secret, :v1_subscription_id
5-
params :first_name, :last_name, :company, :address, :address2, :city, :country, :state, :vat_id, :zip_code, :billing_email, prefix: :billing_info
5+
params :first_name, :last_name, :company, :address, :address2, :city, :country, :state, :vat_id, :zip_code, :billing_email, :has_local_registration, prefix: :billing_info
66
params :token, prefix: :credit_card_info
77

88
def run!

spec/v3/models/v2_subscription_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@
88
'status' => nil,
99
'valid_to' => nil,
1010
'canceled_at' => nil,
11+
'billing_info' => {
12+
'address' => 'Washington str.',
13+
'address2' => '',
14+
'billing_email' => '[email protected]',
15+
'city' => 'Washington',
16+
'company' => 'Travis CI',
17+
'country' => 'United States of America',
18+
'first_name' => 'John',
19+
'last_name' => 'Doe',
20+
'has_local_registration' => true,
21+
'state' => 'Alabama',
22+
'vat_id' => '',
23+
'zip_code' => '2001',
24+
},
1125
'plan_config' => {
1226
'id' => 'pro_tier_plan',
1327
'name' => 'Pro Tier Plan',
@@ -103,6 +117,8 @@
103117
expect(subject.permissions).to be_a(Travis::API::V3::Models::BillingPermissions)
104118
expect(subject.owner).to be_a(Travis::API::V3::Models::User)
105119
expect(subject.payment_intent).to be_a(Travis::API::V3::Models::PaymentIntent)
120+
expect(subject.billing_info).to be_a(Travis::API::V3::Models::V2BillingInfo)
121+
expect(subject.billing_info.has_local_registration).to be true
106122
end
107123
end
108124
end

spec/v3/services/subscription/update_address_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
'country' => 'Germany',
3030
'zip_code' => '10001',
3131
'billing_email' => '[email protected]',
32-
'has_local_registration' => nil
32+
'has_local_registration' => true
3333
} }
3434
let(:subscription_id) { rand(999) }
3535

@@ -44,7 +44,7 @@
4444
'country' => 'Germany',
4545
'zip_code' => '10001',
4646
'billing_email' => '[email protected]',
47-
'has_local_registration' => nil
47+
'has_local_registration' => true
4848
})
4949
.to_return(status: 204)
5050
end

spec/v3/services/v2_subscriptions/all_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@
207207
'last_name' => 'rosas',
208208
'state' => nil,
209209
'vat_id' => '123456',
210-
'zip_code' => '28450'
210+
'zip_code' => '28450',
211+
'has_local_registration' => false,
211212
},
212213
'credit_card_info' => {
213214
'@type' => 'v2_credit_card_info',

spec/v3/services/v2_subscriptions/create_spec.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
'billing_info.country' => 'Germany',
3636
'billing_info.zip_code' => '10001',
3737
'billing_info.billing_email' => '[email protected]',
38+
'billing_info.state' => 'Alabama',
39+
'billing_info.has_local_registration' => true,
3840
'credit_card_info.token' => 'token_from_stripe'
3941
}
4042
end
@@ -56,6 +58,8 @@
5658
'country' => 'Germany',
5759
'zip_code' => '10001',
5860
'billing_email' => '[email protected]',
61+
'state' => 'Alabama',
62+
'has_local_registration' => true
5963
},
6064
'credit_card_info' => {
6165
'token' => 'token_from_stripe'
@@ -161,6 +165,7 @@
161165
'vat_id' => nil,
162166
'zip_code' => '10001',
163167
'billing_email' => '[email protected]',
168+
'has_local_registration' => true,
164169
},
165170
'credit_card_info' => {
166171
'card_owner' => 'Travis Schmidt',
@@ -276,7 +281,8 @@
276281
'city' => 'Berlin',
277282
'state' => nil,
278283
'country' => 'Germany',
279-
'vat_id' => nil
284+
'vat_id' => nil,
285+
'has_local_registration' => true,
280286
},
281287
'credit_card_info' => {
282288
'id' => 1234,

0 commit comments

Comments
 (0)