Commit 4233aea3 authored by charlie ablett's avatar charlie ablett

Merge branch 'dz/357891-move-gitlab-subscription' into 'master'

Move gitlab_subscription file

See merge request gitlab-org/gitlab!84484
parents 197edba5 67e989ce
# frozen_string_literal: true
module API
module Entities
class GitlabSubscription < Grape::Entity
expose :plan do
expose :plan_name, as: :code
expose :plan_title, as: :name
expose :trial
expose :auto_renew
expose :upgradable?, as: :upgradable
expose :exclude_guests?, as: :exclude_guests
end
expose :usage do
expose :seats, as: :seats_in_subscription
expose :seats_in_use
expose :max_seats_used
expose :seats_owed
end
expose :billing do
expose :start_date, as: :subscription_start_date
expose :end_date, as: :subscription_end_date
expose :trial_ends_on
end
end
end
end
# frozen_string_literal: true
module EE
module API
module Entities
class GitlabSubscription < Grape::Entity
expose :plan do
expose :plan_name, as: :code
expose :plan_title, as: :name
expose :trial
expose :auto_renew
expose :upgradable?, as: :upgradable
expose :exclude_guests?, as: :exclude_guests
end
expose :usage do
expose :seats, as: :seats_in_subscription
expose :seats_in_use
expose :max_seats_used
expose :seats_owed
end
expose :billing do
expose :start_date, as: :subscription_start_date
expose :end_date, as: :subscription_end_date
expose :trial_ends_on
end
end
end
end
end
......@@ -82,7 +82,7 @@ module EE
end
desc 'Create a subscription for the namespace' do
success ::EE::API::Entities::GitlabSubscription
success ::API::Entities::GitlabSubscription
end
params do
use :gitlab_subscription_optional_attributes
......@@ -98,24 +98,24 @@ module EE
subscription_params[:trial_starts_on] ||= subscription_params[:start_date] if subscription_params[:trial]
subscription = namespace.create_gitlab_subscription(subscription_params)
if subscription.persisted?
present subscription, with: ::EE::API::Entities::GitlabSubscription
present subscription, with: ::API::Entities::GitlabSubscription
else
render_validation_error!(subscription)
end
end
desc 'Returns the subscription for the namespace' do
success ::EE::API::Entities::GitlabSubscription
success ::API::Entities::GitlabSubscription
end
get ":id/gitlab_subscription", feature_category: :purchase do
namespace = find_namespace!(params[:id])
authorize! :admin_namespace, namespace
present namespace.gitlab_subscription || {}, with: ::EE::API::Entities::GitlabSubscription
present namespace.gitlab_subscription || {}, with: ::API::Entities::GitlabSubscription
end
desc 'Update the subscription for the namespace' do
success ::EE::API::Entities::GitlabSubscription
success ::API::Entities::GitlabSubscription
end
params do
use :gitlab_subscription_optional_attributes
......@@ -133,7 +133,7 @@ module EE
subscription_params[:updated_at] = Time.current
if subscription.update(subscription_params)
present subscription, with: ::EE::API::Entities::GitlabSubscription
present subscription, with: ::API::Entities::GitlabSubscription
else
render_validation_error!(subscription)
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment