-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1212 from travis-ci/pricing_adjustments_master
Pricing adjustments master
- Loading branch information
Showing
36 changed files
with
577 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Travis::API::V3 | ||
class Models::CreditsCalculatorConfig | ||
ATTRS = %w[users minutes os instance_size] | ||
|
||
attr_accessor *ATTRS | ||
|
||
def initialize(attrs) | ||
ATTRS.each { |key| send("#{key}=", attrs[key]) } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Travis::API::V3 | ||
class Models::CreditsResult | ||
ATTRS = %w[users minutes os instance_size credits price] | ||
|
||
attr_accessor *ATTRS | ||
|
||
def initialize(attrs) | ||
ATTRS.each { |key| send("#{key}=", attrs[key]) } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
module Travis::API::V3 | ||
class Models::V2Addon | ||
attr_reader :id, :name, :type, :current_usage | ||
attr_reader :id, :name, :type, :current_usage, :recurring | ||
|
||
def initialize(attrs) | ||
@id = attrs.fetch('id') | ||
@name = attrs.fetch('name') | ||
@type = attrs.fetch('type') | ||
@current_usage = attrs['current_usage'] && Models::V2AddonUsage.new(attrs['current_usage']) | ||
@recurring = attrs['recurring'] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module Travis::API::V3 | ||
class Queries::CreditsCalculator < Query | ||
params :users, :executions | ||
|
||
def calculate(user_id) | ||
client = BillingClient.new(user_id) | ||
client.calculate_credits(params['users'], params['executions']) | ||
end | ||
|
||
def default_config(user_id) | ||
client = BillingClient.new(user_id) | ||
client.credits_calculator_default_config | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module Travis::API::V3 | ||
class Renderer::AutoRefill < ModelRenderer | ||
representation(:standard, :enabled, :threshold, :amount) | ||
representation(:minimal, :enabled, :threshold, :amount) | ||
representation(:standard, :addon_id, :enabled, :threshold, :amount) | ||
representation(:minimal, :addon_id, :enabled, :threshold, :amount) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module Travis::API::V3 | ||
class Renderer::CreditsCalculatorConfig < ModelRenderer | ||
representation(:standard, :users, :minutes, :os, :instance_size) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module Travis::API::V3 | ||
class Renderer::CreditsResult < ModelRenderer | ||
representation(:standard, :users, :minutes, :os, :instance_size, :credits, :price) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module Travis::API::V3 | ||
class Renderer::CreditsResults < CollectionRenderer | ||
type :credits_results | ||
collection_key :credits_results | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
module Travis::API::V3 | ||
class Renderer::Execution < ModelRenderer | ||
representation :minimal, :id, :os, :instance_size, :arch, :virtualization_type, :queue, :job_id, | ||
:repository_id, :owner_id, :owner_type, :plan_id, :sender_id, :credits_consumed, :started_at, | ||
:finished_at, :created_at, :updated_at | ||
:repository_id, :owner_id, :owner_type, :plan_id, :sender_id, :credits_consumed, | ||
:user_license_credits_consumed, :started_at, :finished_at, :created_at, :updated_at | ||
representation :standard, *representations[:minimal] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
module Travis::API::V3 | ||
class Renderer::V2PlanConfig < ModelRenderer | ||
representation(:standard, :id, :name, :private_repos, :starting_price, :starting_users, :private_credits, | ||
:public_credits, :addon_configs, :plan_type, :concurrency_limit, :available_standalone_addons, :trial_plan) | ||
:public_credits, :addon_configs, :plan_type, :concurrency_limit, :available_standalone_addons, :trial_plan, :annual, :auto_refill_thresholds, :auto_refill_amounts) | ||
representation(:minimal, :id, :name, :private_repos, :starting_price, :starting_users, :private_credits, | ||
:public_credits, :addon_configs, :plan_type, :concurrency_limit, :trial_plan) | ||
:public_credits, :addon_configs, :plan_type, :concurrency_limit, :trial_plan, :annual, :auto_refill_thresholds, :auto_refill_amounts) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
lib/travis/api/v3/services/credits_calculator/calculator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module Travis::API::V3 | ||
class Services::CreditsCalculator::Calculator < Service | ||
result_type :credits_results | ||
params :users, :executions | ||
|
||
def run! | ||
raise LoginRequired unless access_control.logged_in? | ||
|
||
result query(:credits_calculator).calculate(access_control.user.id) | ||
end | ||
end | ||
end |
11 changes: 11 additions & 0 deletions
11
lib/travis/api/v3/services/credits_calculator/default_config.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Travis::API::V3 | ||
class Services::CreditsCalculator::DefaultConfig < Service | ||
result_type :credits_calculator_config | ||
|
||
def run! | ||
raise LoginRequired unless access_control.logged_in? | ||
|
||
result query(:credits_calculator).default_config(access_control.user.id) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Travis::API::V3 | ||
class Services::V2Subscription::Cancel < Service | ||
params :reason, :reason_details | ||
|
||
def run! | ||
raise LoginRequired unless access_control.full_access_or_logged_in? | ||
query.cancel(access_control.user.id) | ||
no_content | ||
end | ||
end | ||
end |
10 changes: 10 additions & 0 deletions
10
lib/travis/api/v3/services/v2_subscription/update_auto_refill.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module Travis::API::V3 | ||
class Services::V2Subscription::UpdateAutoRefill < Service | ||
params :addon_id, :threshold, :amount | ||
def run! | ||
raise LoginRequired unless access_control.full_access_or_logged_in? | ||
query.update_auto_refill(access_control.user.id, params['addon_id']) | ||
no_content | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.