Class: LemonSqueezy::Customer
- Inherits:
-
Object
- Object
- OpenStruct
- Object
- LemonSqueezy::Customer
show all
- Defined in:
- lib/lemon_squeezy/models/customer.rb
Class Method Summary
collapse
Methods inherited from Object
#initialize, #to_ostruct
Class Method Details
.create(store_id:, name:, email:, **params) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/lemon_squeezy/models/customer.rb', line 16
def create(store_id:, name:, email:, **params)
body = {
data: {
type: "customers",
attributes: {
name: name,
email: email
}.merge(params),
relationships: {
store: {
data: {
type: "stores",
id: store_id.to_s
}
},
}
}
}
response = Client.post_request("customers", body: body.to_json)
Customer.new(response.body["data"]) if response.success?
end
|
.retrieve(id:) ⇒ Object
11
12
13
14
|
# File 'lib/lemon_squeezy/models/customer.rb', line 11
def retrieve(id:)
response = Client.get_request("customers/#{id}")
Customer.new(response.body["data"]) if response.success?
end
|
.update(id:, **params) ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/lemon_squeezy/models/customer.rb', line 38
def update(id:, **params)
body = {
data: {
type: "customers",
id: id.to_s,
attributes: params
}
}
response = Client.patch_request("customers/#{id}", body: body.to_json)
Customer.new(response.body["data"]) if response.success?
end
|