class MyMoip::Request
Attributes
id[R]
response[R]
Public Class Methods
new(id)
click to toggle source
# File lib/mymoip/request.rb, line 7 def initialize(id) @id = id end
Public Instance Methods
api_call(params, opts = {})
click to toggle source
# File lib/mymoip/request.rb, line 11 def api_call(params, opts = {}) opts[:logger] ||= MyMoip.logger opts[:username] ||= MyMoip.token opts[:password] ||= MyMoip.key unless opts[:username].present? && opts[:password].present? MyMoip.ensure_key_and_token_set! end opts[:logger].info "New #{self.class} being sent to MoIP." opts[:logger].debug "#{self.class} of ##{@id} with #{params.inspect}" url = MyMoip.api_url + params.delete(:path) params[:basic_auth] = { username: opts[:username], password: opts[:password] } @response = HTTParty.send params.delete(:http_method), url, params opts[:logger].debug "#{self.class} of ##{@id} to #{url} had response #{@response.inspect}" end