Skip to content

Commit e63eaa2

Browse files
authored
addons addedd to V2 planconfig endpoint (#1139)
addon_configs added to V2PlanConfig
1 parent d1f8498 commit e63eaa2

File tree

6 files changed

+184
-6
lines changed

6 files changed

+184
-6
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module Travis::API::V3
22
class Models::V2PlanConfig
3-
attr_reader :id, :name, :private_repos, :starting_price, :starting_users, :private_credits, :public_credits
3+
attr_reader :id, :name, :private_repos, :starting_price, :starting_users, :private_credits, :public_credits,
4+
:addon_configs
45

56
def initialize(attrs)
67
@id = attrs.fetch('id')
@@ -10,6 +11,7 @@ def initialize(attrs)
1011
@starting_users = attrs.fetch('starting_users')
1112
@private_credits = attrs.fetch('private_credits')
1213
@public_credits = attrs.fetch('public_credits')
14+
@addon_configs = attrs.fetch('addon_configs')
1315
end
1416
end
1517
end
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
module Travis::API::V3
22
class Renderer::V2PlanConfig < ModelRenderer
3-
representation(:standard, :id, :name, :private_repos, :starting_price, :starting_users, :private_credits, :public_credits)
4-
representation(:minimal, :id, :name, :private_repos, :starting_price, :starting_users, :private_credits, :public_credits)
3+
representation(:standard, :id, :name, :private_repos, :starting_price, :starting_users, :private_credits,
4+
:public_credits, :addon_configs)
5+
representation(:minimal, :id, :name, :private_repos, :starting_price, :starting_users, :private_credits,
6+
:public_credits, :addon_configs)
57
end
68
end

spec/support/billing_spec_helper.rb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,35 @@ def billing_v2_subscription_response_body(attributes={})
5555
'starting_users' => 10000,
5656
'private_credits' => 500000,
5757
'public_credits' => 40000,
58+
'addon_configs' => {
59+
'free_tier_credits' => {
60+
'name' => 'Free 10 000 credits (renewed monthly)',
61+
'expires' => true,
62+
'expires_in' => 1,
63+
'renew_after_expiration' => true,
64+
'price' => 0,
65+
'price_id' => 'price_1234567890',
66+
'price_type' => 'fixed',
67+
'quantity' => 10_000,
68+
'standalone' => false,
69+
'type' => 'credit_private',
70+
'available_for_plans' => '%w[free_tier_plan]'
71+
},
72+
'oss_tier_credits' => {
73+
'name' => 'Free 40 000 credits (renewed monthly)',
74+
'expires' => true,
75+
'expires_in' => 1,
76+
'renew_after_expiration' => true,
77+
'price' => 0,
78+
'price_id' => 'price_0987654321',
79+
'price_type' => 'fixed',
80+
'quantity' => 40_000,
81+
'standalone' => false,
82+
'type' => 'credit_public',
83+
'private_repos' => false,
84+
'available_for_plans' => '%w[free_tier_plan standard_tier_plan pro_tier_plan]'
85+
}
86+
}
5887
},
5988
"addons" => billing_addons_response_body,
6089
"source" => "stripe",

spec/v3/models/v2_subscription_spec.rb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,35 @@
1313
'starting_users' => 10000,
1414
'private_credits' => 500000,
1515
'public_credits' => 40000,
16+
'addon_configs' => {
17+
'free_tier_credits' => {
18+
'name' => 'Free 10 000 credits (renewed monthly)',
19+
'expires' => true,
20+
'expires_in' => 1,
21+
'renew_after_expiration' => true,
22+
'price' => 0,
23+
'price_id' => 'price_1234567890',
24+
'price_type' => 'fixed',
25+
'quantity' => 10_000,
26+
'standalone' => false,
27+
'type' => 'credit_private',
28+
'available_for_plans' => '%w[free_tier_plan]'
29+
},
30+
'oss_tier_credits' => {
31+
'name' => 'Free 40 000 credits (renewed monthly)',
32+
'expires' => true,
33+
'expires_in' => 1,
34+
'renew_after_expiration' => true,
35+
'price' => 0,
36+
'price_id' => 'price_0987654321',
37+
'price_type' => 'fixed',
38+
'quantity' => 40_000,
39+
'standalone' => false,
40+
'type' => 'credit_public',
41+
'private_repos' => false,
42+
'available_for_plans' => '%w[free_tier_plan standard_tier_plan pro_tier_plan]'
43+
}
44+
}
1645
},
1746
'addons' => [{
1847
'id' => 7,

spec/v3/services/v2_subscriptions/all_spec.rb

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,36 @@
3131
'starting_price': 30_000,
3232
'starting_users': 10_000,
3333
'private_credits': 500_000,
34-
'public_credits': 40_000
34+
'public_credits': 40_000,
35+
'addon_configs' => {
36+
'free_tier_credits' => {
37+
'name' => 'Free 10 000 credits (renewed monthly)',
38+
'expires' => true,
39+
'expires_in' => 1,
40+
'renew_after_expiration' => true,
41+
'price' => 0,
42+
'price_id' => 'price_1234567890',
43+
'price_type' => 'fixed',
44+
'quantity' => 10_000,
45+
'standalone' => false,
46+
'type' => 'credit_private',
47+
'available_for_plans' => '%w[free_tier_plan]'
48+
},
49+
'oss_tier_credits' => {
50+
'name' => 'Free 40 000 credits (renewed monthly)',
51+
'expires' => true,
52+
'expires_in' => 1,
53+
'renew_after_expiration' => true,
54+
'price' => 0,
55+
'price_id' => 'price_0987654321',
56+
'price_type' => 'fixed',
57+
'quantity' => 40_000,
58+
'standalone' => false,
59+
'type' => 'credit_public',
60+
'private_repos' => false,
61+
'available_for_plans' => '%w[free_tier_plan standard_tier_plan pro_tier_plan]'
62+
}
63+
}
3564
}
3665
end
3766

@@ -59,7 +88,36 @@
5988
'starting_price' => 30_000,
6089
'starting_users' => 10_000,
6190
'private_credits' => 500_000,
62-
'public_credits' => 40_000
91+
'public_credits' => 40_000,
92+
'addon_configs' => {
93+
'free_tier_credits' => {
94+
'name' => 'Free 10 000 credits (renewed monthly)',
95+
'expires' => true,
96+
'expires_in' => 1,
97+
'renew_after_expiration' => true,
98+
'price' => 0,
99+
'price_id' => 'price_1234567890',
100+
'price_type' => 'fixed',
101+
'quantity' => 10_000,
102+
'standalone' => false,
103+
'type' => 'credit_private',
104+
'available_for_plans' => '%w[free_tier_plan]'
105+
},
106+
'oss_tier_credits' => {
107+
'name' => 'Free 40 000 credits (renewed monthly)',
108+
'expires' => true,
109+
'expires_in' => 1,
110+
'renew_after_expiration' => true,
111+
'price' => 0,
112+
'price_id' => 'price_0987654321',
113+
'price_type' => 'fixed',
114+
'quantity' => 40_000,
115+
'standalone' => false,
116+
'type' => 'credit_public',
117+
'private_repos' => false,
118+
'available_for_plans' => '%w[free_tier_plan standard_tier_plan pro_tier_plan]'
119+
}
120+
}
63121
},
64122
'addons' => [
65123
{

spec/v3/services/v2_subscriptions/create_spec.rb

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,35 @@
7171
'starting_users' => 10_000,
7272
'private_credits' => 500_000,
7373
'public_credits' => 40_000,
74+
'addon_configs' => {
75+
'free_tier_credits' => {
76+
'name' => 'Free 10 000 credits (renewed monthly)',
77+
'expires' => true,
78+
'expires_in' => 1,
79+
'renew_after_expiration' => true,
80+
'price' => 0,
81+
'price_id' => 'price_1234567890',
82+
'price_type' => 'fixed',
83+
'quantity' => 10_000,
84+
'standalone' => false,
85+
'type' => 'credit_private',
86+
'available_for_plans' => '%w[free_tier_plan]'
87+
},
88+
'oss_tier_credits' => {
89+
'name' => 'Free 40 000 credits (renewed monthly)',
90+
'expires' => true,
91+
'expires_in' => 1,
92+
'renew_after_expiration' => true,
93+
'price' => 0,
94+
'price_id' => 'price_0987654321',
95+
'price_type' => 'fixed',
96+
'quantity' => 40_000,
97+
'standalone' => false,
98+
'type' => 'credit_public',
99+
'private_repos' => false,
100+
'available_for_plans' => '%w[free_tier_plan standard_tier_plan pro_tier_plan]'
101+
}
102+
}
74103
},
75104
'addons' => [{
76105
'id': 7,
@@ -135,7 +164,36 @@
135164
'starting_users' => 10_000,
136165
'starting_price' => 30_000,
137166
'private_credits' => 500_000,
138-
'public_credits' => 40_000
167+
'public_credits' => 40_000,
168+
'addon_configs' => {
169+
'free_tier_credits' => {
170+
'name' => 'Free 10 000 credits (renewed monthly)',
171+
'expires' => true,
172+
'expires_in' => 1,
173+
'renew_after_expiration' => true,
174+
'price' => 0,
175+
'price_id' => 'price_1234567890',
176+
'price_type' => 'fixed',
177+
'quantity' => 10_000,
178+
'standalone' => false,
179+
'type' => 'credit_private',
180+
'available_for_plans' => '%w[free_tier_plan]'
181+
},
182+
'oss_tier_credits' => {
183+
'name' => 'Free 40 000 credits (renewed monthly)',
184+
'expires' => true,
185+
'expires_in' => 1,
186+
'renew_after_expiration' => true,
187+
'price' => 0,
188+
'price_id' => 'price_0987654321',
189+
'price_type' => 'fixed',
190+
'quantity' => 40_000,
191+
'standalone' => false,
192+
'type' => 'credit_public',
193+
'private_repos' => false,
194+
'available_for_plans' => '%w[free_tier_plan standard_tier_plan pro_tier_plan]'
195+
}
196+
}
139197
},
140198
'addons' => [{
141199
'@type' => 'v2_addon',

0 commit comments

Comments
 (0)