Class: Lago::Api::Resources::Base
- Inherits:
-
Object
- Object
- Lago::Api::Resources::Base
show all
- Defined in:
- lib/lago/api/resources/base.rb
Direct Known Subclasses
ActivityLog, AddOn, ApiLog, AppliedCoupon, BillableMetric, BillingEntity, Coupon, CreditNote, Customer, Customers::Base, Event, Feature, Fee, GrossRevenue, Invoice, InvoiceCollection, InvoicedUsage, Mrr, Organization, OverdueBalance, Payment, PaymentReceipt, PaymentRequest, Plan, Subscription, Tax, Usage, Wallet, WalletTransaction, Webhook, WebhookEndpoint
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(client) ⇒ Base
Returns a new instance of Base.
9
10
11
|
# File 'lib/lago/api/resources/base.rb', line 9
def initialize(client)
@client = client
end
|
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
7
8
9
|
# File 'lib/lago/api/resources/base.rb', line 7
def client
@client
end
|
Instance Method Details
#api_resource ⇒ Object
13
14
15
|
# File 'lib/lago/api/resources/base.rb', line 13
def api_resource
raise NotImplementedError
end
|
#create(params) ⇒ Object
25
26
27
28
29
30
|
# File 'lib/lago/api/resources/base.rb', line 25
def create(params)
payload = whitelist_params(params)
response = connection.post(payload)[root_name]
JSON.parse(response.to_json, object_class: OpenStruct)
end
|
#destroy(identifier, options: nil) ⇒ Object
45
46
47
48
49
|
# File 'lib/lago/api/resources/base.rb', line 45
def destroy(identifier, options: nil)
response = connection.destroy(identifier: identifier, options: options)[root_name]
JSON.parse(response.to_json, object_class: OpenStruct)
end
|
#get(identifier) ⇒ Object
39
40
41
42
43
|
# File 'lib/lago/api/resources/base.rb', line 39
def get(identifier)
response = connection.get(identifier: identifier)[root_name]
JSON.parse(response.to_json, object_class: OpenStruct)
end
|
#get_all(options = {}) ⇒ Object
51
52
53
54
55
|
# File 'lib/lago/api/resources/base.rb', line 51
def get_all(options = {})
response = connection.get_all(options)
JSON.parse(response.to_json, object_class: OpenStruct)
end
|
#root_name ⇒ Object
17
18
19
|
# File 'lib/lago/api/resources/base.rb', line 17
def root_name
raise NotImplementedError
end
|
#update(params, identifier = nil) ⇒ Object
32
33
34
35
36
37
|
# File 'lib/lago/api/resources/base.rb', line 32
def update(params, identifier = nil)
payload = whitelist_params(params)
response = connection.put(identifier: identifier, body: payload)[root_name]
JSON.parse(response.to_json, object_class: OpenStruct)
end
|
#whitelist_params(_params) ⇒ Object
21
22
23
|
# File 'lib/lago/api/resources/base.rb', line 21
def whitelist_params(_params)
raise NotImplementedError
end
|