Class: Stigg::Resources::V1::Addons::Entitlements

Inherits:
Object
  • Object
show all
Defined in:
lib/stigg/resources/v1/addons/entitlements.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Entitlements

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Entitlements.

Parameters:



155
156
157
# File 'lib/stigg/resources/v1/addons/entitlements.rb', line 155

def initialize(client:)
  @client = client
end

Instance Method Details

#create(addon_id, entitlements:, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::Addons::EntitlementCreateResponse

Some parameter documentations has been truncated, see Models::V1::Addons::EntitlementCreateParams for more details.

Creates one or more entitlements (feature or credit) on a draft addon.

Parameters:

Returns:

See Also:



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/stigg/resources/v1/addons/entitlements.rb', line 28

def create(addon_id, params)
  parsed, options = Stigg::V1::Addons::EntitlementCreateParams.dump_request(params)
  header_params = {x_account_id: "x-account-id", x_environment_id: "x-environment-id"}
  @client.request(
    method: :post,
    path: ["api/v1/addons/%1$s/entitlements", addon_id],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Stigg::Models::V1::Addons::EntitlementCreateResponse,
    options: options
  )
end

#delete(id, addon_id:, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::Addons::AddonPackageEntitlement

Some parameter documentations has been truncated, see Models::V1::Addons::EntitlementDeleteParams for more details.

Deletes an entitlement from a draft addon.

Parameters:

  • id (String)

    Path param: The feature ID or custom currency ID of the entitlement

  • addon_id (String)

    Path param: The addon ID

  • x_account_id (String)

    Header param: Account ID — optional when authenticating with a user JWT (Bearer

  • x_environment_id (String)

    Header param: Environment ID — required when authenticating with a user JWT (Bea

  • request_options (Stigg::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/stigg/resources/v1/addons/entitlements.rb', line 134

def delete(id, params)
  parsed, options = Stigg::V1::Addons::EntitlementDeleteParams.dump_request(params)
  addon_id =
    parsed.delete(:addon_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: ["api/v1/addons/%1$s/entitlements/%2$s", addon_id, id],
    headers: parsed.transform_keys(
      x_account_id: "x-account-id",
      x_environment_id: "x-environment-id"
    ),
    model: Stigg::V1::Addons::AddonPackageEntitlement,
    options: options
  )
end

#list(addon_id, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::Addons::EntitlementListResponse

Some parameter documentations has been truncated, see Models::V1::Addons::EntitlementListParams for more details.

Retrieves a list of entitlements for an addon.

Parameters:

  • addon_id (String)

    The addon ID

  • x_account_id (String)

    Account ID — optional when authenticating with a user JWT (Bearer token); falls

  • x_environment_id (String)

    Environment ID — required when authenticating with a user JWT (Bearer token) on

  • request_options (Stigg::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/stigg/resources/v1/addons/entitlements.rb', line 100

def list(addon_id, params = {})
  parsed, options = Stigg::V1::Addons::EntitlementListParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["api/v1/addons/%1$s/entitlements", addon_id],
    headers: parsed.transform_keys(
      x_account_id: "x-account-id",
      x_environment_id: "x-environment-id"
    ),
    model: Stigg::Models::V1::Addons::EntitlementListResponse,
    options: options
  )
end

#update(id, addon_id:, body:, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::Addons::AddonPackageEntitlement

Some parameter documentations has been truncated, see Models::V1::Addons::EntitlementUpdateParams for more details.

Updates an existing entitlement on a draft addon.

Parameters:

Returns:

See Also:



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/stigg/resources/v1/addons/entitlements.rb', line 63

def update(id, params)
  parsed, options = Stigg::V1::Addons::EntitlementUpdateParams.dump_request(params)
  addon_id =
    parsed.delete(:addon_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :patch,
    path: ["api/v1/addons/%1$s/entitlements/%2$s", addon_id, id],
    headers: parsed.except(:body).transform_keys(
      x_account_id: "x-account-id",
      x_environment_id: "x-environment-id"
    ),
    body: parsed[:body],
    model: Stigg::V1::Addons::AddonPackageEntitlement,
    options: options
  )
end