Class: Nabortu::Client
- Inherits:
-
Object
show all
- Defined in:
- lib/nabortu/client.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, params, args = {}) ⇒ Object
15
16
17
18
19
20
21
22
23
|
# File 'lib/nabortu/client.rb', line 15
def method_missing(name, params, args = {})
klass = ['Nabortu', 'Methods', name.to_s.camelize].join('::')
if Object.const_defined? klass
klass.constantize.do_request(name, params)
else
raise Nabortu::Errors::WrongMethod.new("Nabortu API does not have '#{name}' method or it\'s not implemented")
end
end
|
Instance Method Details
#send_payment(reserve_id) ⇒ Object
6
7
8
9
10
11
12
13
|
# File 'lib/nabortu/client.rb', line 6
def send_payment(reserve_id)
url = URI.parse(Nabortu.config.payment_url)
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url.path, {'Content-Type' =>'application/json'})
request.body = {orderId: reserve_id.to_s}.to_json
http.request(request)
end
|