Class: CoinbaseCommerce::APIResources::Base::APIResource

Inherits:
APIObject
  • Object
show all
Defined in:
lib/coinbase_commerce/api_resources/base/api_resource.rb

Overview

Base resource class if you need to add additional API resource, inherit from APIResource

Direct Known Subclasses

Charge, Checkout, Event

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from APIObject

#[], #[]=, create_from, #each, #initialize, #initialize_from, #inspect, #keys, #method_missing, #respond_to_missing?, #serialize_params, #serialize_params_value, #to_hash, #to_json, #to_s, #update_attributes, #values

Constructor Details

This class inherits a constructor from CoinbaseCommerce::APIResources::Base::APIObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class CoinbaseCommerce::APIResources::Base::APIObject

Class Attribute Details

.clientObject

Returns the value of attribute client.



8
9
10
# File 'lib/coinbase_commerce/api_resources/base/api_resource.rb', line 8

def client
  @client
end

Class Method Details

.retrieve(id, params = {}) ⇒ Object



13
14
15
16
# File 'lib/coinbase_commerce/api_resources/base/api_resource.rb', line 13

def self.retrieve(id, params = {})
  resp = @client.request(:get, "#{self::RESOURCE_PATH}/#{id}", params)
  Util.convert_to_api_object(resp.data, @client, self)
end

Instance Method Details

#refresh(params = {}) ⇒ Object



18
19
20
21
# File 'lib/coinbase_commerce/api_resources/base/api_resource.rb', line 18

def refresh(params = {})
  resp = @client.request(:get, "#{self.class::RESOURCE_PATH}/#{self[:id]}", params)
  initialize_from(resp.data)
end