Class: CoinJarCheckout::Client
- Inherits:
-
Object
- Object
- CoinJarCheckout::Client
- Defined in:
- lib/coinjar-checkout/client.rb
Instance Method Summary collapse
- #delete(path) ⇒ Object
- #get(path, params = nil) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #parse(response) ⇒ Object
- #patch(path, payload) ⇒ Object
- #post(path, payload) ⇒ Object
- #put(path, payload) ⇒ Object
- #url(path) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
6 7 8 9 10 11 12 |
# File 'lib/coinjar-checkout/client.rb', line 6 def initialize(={}) = CoinJarCheckout..merge() Configuration::VALID_CONFIG_KEYS.each do |key| send("#{key}=", [key]) end @root_resource = RestClient::Resource.new(endpoint, user: uuid, password: secret) end |
Instance Method Details
#delete(path) ⇒ Object
26 27 28 |
# File 'lib/coinjar-checkout/client.rb', line 26 def delete(path) parse url(path).delete end |
#get(path, params = nil) ⇒ Object
18 19 20 |
# File 'lib/coinjar-checkout/client.rb', line 18 def get(path, params = nil) parse url(path).get(:params => params) end |
#parse(response) ⇒ Object
34 35 36 |
# File 'lib/coinjar-checkout/client.rb', line 34 def parse(response) MultiJson.load(response, :symbolize_keys => true) end |
#patch(path, payload) ⇒ Object
30 31 32 |
# File 'lib/coinjar-checkout/client.rb', line 30 def patch(path, payload) parse url(path).patch(payload) end |
#post(path, payload) ⇒ Object
14 15 16 |
# File 'lib/coinjar-checkout/client.rb', line 14 def post(path, payload) parse url(path).post(payload) end |
#put(path, payload) ⇒ Object
22 23 24 |
# File 'lib/coinjar-checkout/client.rb', line 22 def put(path, payload) parse url(path).put(payload) end |
#url(path) ⇒ Object
38 39 40 |
# File 'lib/coinjar-checkout/client.rb', line 38 def url(path) root_resource["#{path}.#{format}"] end |