Class: BuyonApi::Client
- Inherits:
-
Object
- Object
- BuyonApi::Client
- Defined in:
- lib/buyon_api/client.rb
Instance Method Summary collapse
-
#initialize ⇒ Client
constructor
A new instance of Client.
- #method_missing(m, args, &block) ⇒ Object
- #obj_hash(result) ⇒ Object
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, args, &block) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/buyon_api/client.rb', line 8 def method_missing(m, args, &block) result = @conn.post do |req| req.url m.to_s req.headers['Content-Type'] = 'application/json' req.params = args end obj_hash JSON.parse(result.body) end |
Instance Method Details
#obj_hash(result) ⇒ Object
18 19 20 |
# File 'lib/buyon_api/client.rb', line 18 def obj_hash(result) OpenStruct.new(result) end |