Class: Dodopayments::Resources::LicenseKeys

Inherits:
Object
  • Object
show all
Defined in:
lib/dodopayments/resources/license_keys.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ LicenseKeys

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 LicenseKeys.

Parameters:



126
127
128
# File 'lib/dodopayments/resources/license_keys.rb', line 126

def initialize(client:)
  @client = client
end

Instance Method Details

#create(customer_id:, key:, product_id:, activations_limit: nil, expires_at: nil, request_options: {}) ⇒ Dodopayments::Models::LicenseKey

Parameters:

  • customer_id (String)

    The customer this license key belongs to.

  • key (String)

    The license key string to import.

  • product_id (String)

    The product this license key is for.

  • activations_limit (Integer, nil)

    Maximum number of activations allowed. Null means unlimited.

  • expires_at (Time, nil)

    Expiration timestamp. Null means the key never expires.

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

Returns:

See Also:



23
24
25
26
27
28
29
30
31
32
# File 'lib/dodopayments/resources/license_keys.rb', line 23

def create(params)
  parsed, options = Dodopayments::LicenseKeyCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "license_keys",
    body: parsed,
    model: Dodopayments::LicenseKey,
    options: options
  )
end

#list(created_at_gte: nil, created_at_lte: nil, customer_id: nil, page_number: nil, page_size: nil, product_id: nil, source: nil, status: nil, request_options: {}) ⇒ Dodopayments::Internal::DefaultPageNumberPagination<Dodopayments::Models::LicenseKey>

Deprecated.

Parameters:

  • created_at_gte (Time)

    Filter license keys created on or after this timestamp

  • created_at_lte (Time)

    Filter license keys created on or before this timestamp

  • customer_id (String)

    Filter by customer ID

  • page_number (Integer)

    Page number default is 0

  • page_size (Integer)

    Page size default is 10 max is 100

  • product_id (String)

    Filter by product ID

  • source (Symbol, Dodopayments::Models::LicenseKeyListParams::Source)

    Filter by license key source

  • status (Symbol, Dodopayments::Models::LicenseKeyListParams::Status)

    Filter by license key status

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

Returns:

See Also:



110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/dodopayments/resources/license_keys.rb', line 110

def list(params = {})
  parsed, options = Dodopayments::LicenseKeyListParams.dump_request(params)
  query = Dodopayments::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "license_keys",
    query: query,
    page: Dodopayments::Internal::DefaultPageNumberPagination,
    model: Dodopayments::LicenseKey,
    options: options
  )
end

#retrieve(id, request_options: {}) ⇒ Dodopayments::Models::LicenseKey

Deprecated.

Parameters:

Returns:

See Also:



45
46
47
48
49
50
51
52
# File 'lib/dodopayments/resources/license_keys.rb', line 45

def retrieve(id, params = {})
  @client.request(
    method: :get,
    path: ["license_keys/%1$s", id],
    model: Dodopayments::LicenseKey,
    options: params[:request_options]
  )
end

#update(id, activations_limit: nil, disabled: nil, expires_at: nil, request_options: {}) ⇒ Dodopayments::Models::LicenseKey

Deprecated.

Some parameter documentations has been truncated, see Models::LicenseKeyUpdateParams for more details.

Parameters:

  • id (String)

    License key ID

  • activations_limit (Integer, nil)

    The updated activation limit for the license key.

  • disabled (Boolean, nil)

    Indicates whether the license key should be disabled.

  • expires_at (Time, nil)

    The updated expiration timestamp for the license key in UTC.

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

Returns:

See Also:



74
75
76
77
78
79
80
81
82
83
# File 'lib/dodopayments/resources/license_keys.rb', line 74

def update(id, params = {})
  parsed, options = Dodopayments::LicenseKeyUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["license_keys/%1$s", id],
    body: parsed,
    model: Dodopayments::LicenseKey,
    options: options
  )
end