Skip to content

Commit 31f33d0

Browse files
committed
Adjustments for billing-v2 plan change
1 parent ab0a6bf commit 31f33d0

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

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

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,42 @@ def initialize(attributes = {})
1111
@permissions = Models::BillingPermissions.new(attributes.fetch('permissions'))
1212
@status = 'subscribed'
1313
@source = attributes.fetch('source')
14-
@billing_info = attributes['billing_info'] && Models::BillingInfo.new(@id, attributes['billing_info'])
15-
@credit_card_info = attributes['credit_card_info'] && Models::CreditCardInfo.new(@id, attributes['credit_card_info'])
14+
@billing_info = attributes['billing_info'] && Models::V2BillingInfo.new(@id, attributes['billing_info'])
15+
@credit_card_info = attributes['credit_card_info'] && Models::V2CreditCardInfo.new(@id, attributes['credit_card_info'])
1616
@payment_intent = attributes['payment_intent'] && Models::PaymentIntent.new(attributes['payment_intent'])
1717
@owner = fetch_owner(attributes.fetch('owner'))
1818
@addons = attributes.fetch('addons')
1919
@created_at = attributes.fetch('created_at')
2020
end
2121
end
22+
23+
class Models::V2BillingInfo
24+
attr_reader :id, :address, :address2, :billing_email, :city, :company, :country, :first_name, :last_name, :state, :vat_id, :zip_code
25+
26+
def initialize(id, attrs)
27+
@id = id
28+
@address = attrs.fetch('address')
29+
@address2 = attrs.fetch('address2')
30+
@billing_email = attrs.fetch('billing_email')
31+
@city = attrs.fetch('city')
32+
@company = attrs.fetch('company')
33+
@country = attrs.fetch('country')
34+
@first_name = attrs.fetch('first_name')
35+
@last_name = attrs.fetch('last_name')
36+
@state = attrs.fetch('state')
37+
@vat_id = attrs.fetch('vat_id')
38+
@zip_code = attrs.fetch('zip_code')
39+
end
40+
end
41+
42+
class Models::V2CreditCardInfo
43+
attr_reader :id, :card_owner, :expiration_date, :last_digits
44+
45+
def initialize(id, attrs)
46+
@id = id
47+
@card_owner = attrs.fetch('card_owner')
48+
@expiration_date = attrs.fetch('expiration_date')
49+
@last_digits = attrs.fetch('last_digits')
50+
end
51+
end
2252
end

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,12 @@ def payment_intent
1818
Renderer.render_model(model.payment_intent, mode: :standard) unless model.payment_intent.nil?
1919
end
2020
end
21+
22+
class Renderer::V2BillingInfo < ModelRenderer
23+
representation(:standard, :id, :address, :address2, :billing_email, :city, :company, :country, :first_name, :last_name, :state, :vat_id, :zip_code)
24+
end
25+
26+
class Renderer::V2CreditCardInfo < ModelRenderer
27+
representation(:standard, :id, :card_owner, :expiration_date, :last_digits)
28+
end
2129
end

0 commit comments

Comments
 (0)