Class: Pago::V2026_04::Services::LicenseKeys

Inherits:
Service
  • Object
show all
Defined in:
lib/pago/v2026_04/services/license_keys.rb,
sig/pago/v2026_04/generated.rbs

Instance Attribute Summary

Attributes inherited from Service

#client

Instance Method Summary collapse

Methods inherited from Service

#initialize

Constructor Details

This class inherits a constructor from Pago::Service

Instance Method Details

#activate(body: {}) ⇒ Models::LicenseKeyActivationRead

Activate a license key instance.

Scopes: license_keys:write

Parameters:

Returns:

Raises:



145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/pago/v2026_04/services/license_keys.rb', line 145

def activate(body: {})
  data = client.request(
    http_method: "POST",
    path: "/v1/license-keys/activate",
    path_params: {},
    query: {},
    body: body,
    response_type: :json,
    errors: { 403 => Errors::NotPermitted, 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
  )
  Models::LicenseKeyActivationRead.from_json(data)
end

#deactivate(body: {}) ⇒ nil

Deactivate a license key instance.

Scopes: license_keys:write

Parameters:

Returns:

  • (nil)

Raises:



167
168
169
170
171
172
173
174
175
176
177
# File 'lib/pago/v2026_04/services/license_keys.rb', line 167

def deactivate(body: {})
  client.request(
    http_method: "POST",
    path: "/v1/license-keys/deactivate",
    path_params: {},
    query: {},
    body: body,
    response_type: :none,
    errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
  )
end

#get(id) ⇒ Models::LicenseKeyWithActivations

Get a license key.

Scopes: license_keys:read license_keys:write

Parameters:

  • id (String)

Returns:

Raises:



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/pago/v2026_04/services/license_keys.rb', line 54

def get(id)
  data = client.request(
    http_method: "GET",
    path: "/v1/license-keys/{id}",
    path_params: { "id" => id },
    query: {},
    response_type: :json,
    errors: { 401 => Errors::Unauthorized, 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
  )
  Models::LicenseKeyWithActivations.from_json(data)
end

#get_activation(id, activation_id) ⇒ Models::LicenseKeyActivationRead

Get a license key activation.

Scopes: license_keys:read license_keys:write

Parameters:

  • id (String)
  • activation_id (String)

Returns:

Raises:



101
102
103
104
105
106
107
108
109
110
111
# File 'lib/pago/v2026_04/services/license_keys.rb', line 101

def get_activation(id, activation_id)
  data = client.request(
    http_method: "GET",
    path: "/v1/license-keys/{id}/activations/{activation_id}",
    path_params: { "id" => id, "activation_id" => activation_id },
    query: {},
    response_type: :json,
    errors: { 401 => Errors::Unauthorized, 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
  )
  Models::LicenseKeyActivationRead.from_json(data)
end

#list(organization_id: nil, benefit_id: nil, status: nil, page: 1, limit: 10) ⇒ Models::ListResourceLicenseKeyRead

Get license keys connected to the given organization & filters.

Scopes: license_keys:read license_keys:write

Parameters:

  • organization_id (String, Array<String>, nil) (defaults to: nil)

    Filter by organization ID.

  • benefit_id (String, Array<String>, nil) (defaults to: nil)

    Filter by benefit ID.

  • status (String, Array<String>, nil) (defaults to: nil)

    Filter by license key status.

  • page (Integer) (defaults to: 1)

    Page number, defaults to 1.

  • limit (Integer) (defaults to: 10)

    Size of a page, defaults to 10. Maximum is 100.

  • organization_id: (Object) (defaults to: nil)
  • benefit_id: (Object) (defaults to: nil)
  • status: (Object) (defaults to: nil)
  • page: (Integer, nil) (defaults to: 1)
  • limit: (Integer, nil) (defaults to: 10)

Returns:

Raises:



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/pago/v2026_04/services/license_keys.rb', line 21

def list(organization_id: nil, benefit_id: nil, status: nil, page: 1, limit: 10)
  data = client.request(
    http_method: "GET",
    path: "/v1/license-keys/",
    path_params: {},
    query: { "organization_id" => organization_id, "benefit_id" => benefit_id, "status" => status, "page" => page, "limit" => limit },
    response_type: :json,
    errors: { 401 => Errors::Unauthorized, 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
  )
  Models::ListResourceLicenseKeyRead.from_json(data)
end

#list_each(organization_id: nil, benefit_id: nil, status: nil, limit: 10) {|item| ... } ⇒ Pago::Paginator

Enumerate every item of list, fetching pages on demand.

Parameters:

  • organization_id: (Object) (defaults to: nil)
  • benefit_id: (Object) (defaults to: nil)
  • status: (Object) (defaults to: nil)
  • limit: (Integer, nil) (defaults to: 10)

Yield Parameters:

Returns:



37
38
39
40
41
42
# File 'lib/pago/v2026_04/services/license_keys.rb', line 37

def list_each(organization_id: nil, benefit_id: nil, status: nil, limit: 10, &block)
  paginator = ::Pago::Paginator.new do |page_number|
    list(organization_id: organization_id, benefit_id: benefit_id, status: status, page: page_number, limit: limit)
  end
  block ? paginator.each(&block) : paginator
end

#update(id, body: {}) ⇒ Models::LicenseKeyRead

Update a license key.

Scopes: license_keys:write

Parameters:

  • id (String)
  • body (Hash, Models::LicenseKeyUpdate) (defaults to: {})

    the request body.

  • body: (Object) (defaults to: {})

Returns:

Raises:



77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/pago/v2026_04/services/license_keys.rb', line 77

def update(id, body: {})
  data = client.request(
    http_method: "PATCH",
    path: "/v1/license-keys/{id}",
    path_params: { "id" => id },
    query: {},
    body: body,
    response_type: :json,
    errors: { 401 => Errors::Unauthorized, 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
  )
  Models::LicenseKeyRead.from_json(data)
end

#validate(body: {}) ⇒ Models::ValidatedLicenseKey

Validate a license key.

Scopes: license_keys:write

Parameters:

Returns:

Raises:



122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/pago/v2026_04/services/license_keys.rb', line 122

def validate(body: {})
  data = client.request(
    http_method: "POST",
    path: "/v1/license-keys/validate",
    path_params: {},
    query: {},
    body: body,
    response_type: :json,
    errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
  )
  Models::ValidatedLicenseKey.from_json(data)
end