Class: LemonSqueezy::LicenseKey

Inherits:
Object
  • Object
show all
Defined in:
lib/lemon_squeezy/models/license_key.rb

Class Method Summary collapse

Methods inherited from Object

#initialize, #to_ostruct

Constructor Details

This class inherits a constructor from LemonSqueezy::Object

Class Method Details

.list(**params) ⇒ Object



6
7
8
9
# File 'lib/lemon_squeezy/models/license_key.rb', line 6

def list(**params)
  response = Client.get_request("license-keys", params: {filter: params})
  Collection.from_response(response, type: LicenseKey)
end

.retrieve(id:) ⇒ Object



11
12
13
14
# File 'lib/lemon_squeezy/models/license_key.rb', line 11

def retrieve(id:)
  response = Client.get_request("license-keys/#{id}")
  LicenseKey.new(response.body["data"]) if response.success?
end

.update(id:, **attributes) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/lemon_squeezy/models/license_key.rb', line 16

def update(id:, **attributes)
  body = {
    data: {
      type: "license-keys",
      id: id.to_s,
      attributes: attributes
    }
  }

  response = Client.patch_request("license-keys/#{id}", body: body.to_json)
  LicenseKey.new(response.body["data"]) if response.success?
end