Class: IGE_ISB_API::Request
- Inherits:
-
Object
- Object
- IGE_ISB_API::Request
- Defined in:
- lib/ige_isb_api/request.rb
Constant Summary collapse
- DEFAULT_PARAMS =
{ 'secretkey' => IGE_ISB_API::Constants::SECRET_KEY }
- COMMON_FIELDS =
{ 'command' => {:required => true, :type => 'string', :length => 32}, 'idrequest' => {:required => true, :type => 'string', :length => 32}, 'secretkey' => {:required => true, :type => 'string', :length => 128}, 'username' => {:required => true, :type => 'username', :length => 32}, 'password' => {:required => true, :type => 'password', :length => 32}, # this differs from the docs but testing shows it's true. 'txid' => {:required => true, :type => 'int'} }
- COMMANDS =
{ 'registration' => { 'email' => {:required => true, :type => 'email', :length => 140}, 'name' => {:required => true, :type => 'name', :length => 140}, 'firstname' => {:required => true, :type => 'name', :length => 140}, 'zip' => {:required => true, :type => 'string', :length => 10}, 'city' => {:required => true, :type => 'string', :length => 140}, 'phone' => {:required => true, :type => 'phone', :length => 32}, 'dob' => {:required => true, :type => 'datestring', :length => 10}, 'country' => {:required => true, :type => 'country'}, 'ip' => {:required => true, :type => 'ip4', :length => 32}, 'cur' => {:required => true, :type => 'currency_code', :length => 3}, 'status' => {:required => true, :type => 'int', values: [0, 1, 2]}, 'carte' => {:required => true, :type => 'string', :length => 32}, 'lang' => {:required => true, :type => 'string', :length => 2}, 'gender' => {:required => true, :type => 'int', values: [0, 1]}, 'idaffiliation' => {:required => true, :type => 'int'} }, 'login' => { 'carte' => {:required => true, :type => 'string', :length => 32} }, 'deposit' => { 'amount' => {:required => true, :type => 'int'}, 'reference' => {:required => true, :type => 'string', :length => 32}, 'cur' => {:required => true, :type => 'string', :length => 3}, 'wallet' => {:required => true, :type => 'string', :length => 32} }, 'withdrawal' => { 'amount' => {:required => true, :type => 'int'}, 'reference' => {:required => true, :type => 'string', :length => 32}, 'cur' => {:required => true, :type => 'currency_code', :length => 3}, 'wallet' => {:required => true, :type => 'string', :length => 32}, 'creditcardnumber' => {:required => true, :type => 'string', :length => 32} }, 'cancel_withdrawal' => { 'withdrawalid' => {:required => true, :type => 'int'} }, 'get_history' => { # nothing special }, 'send_email' => { 'email' => {:required => true, :type => 'string', :length => 32}, 'carte' => {:required => true, :type => 'string', :length => 32}, 'emailtemplate' => {:required => true, :type => 'string', :length => 32}, 'emailparameters' => {:required => true, :type => 'string'} }, 'limits' => { 'limitationtype' => {:required => true, :type => 'limit'}, 'amount' => {:required => true, :type => 'int'}, 'frequency' => {:required => true, :type => 'timespan'}, 'until' => {:required => true, :type => 'string', :length => 32} }, 'userstatus' => { 'flag' => {:required => true, :type => 'int'} }, 'pass' => { 'newpassword' => {:required => true, :type => 'string', :length => 32} }, 'get_vip_points' => { # nothing special }, 'save_friend_email' => { 'invitedname' => {:required => true, :type => 'string', :length => 32}, 'invitedemail' => {:required => true, :type => 'string', :length => 140} } }
Instance Attribute Summary collapse
-
#params ⇒ Object
Returns the value of attribute params.
-
#request ⇒ Object
Returns the value of attribute request.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Request
constructor
A new instance of Request.
- #send ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Request
Returns a new instance of Request.
94 95 96 97 98 99 100 |
# File 'lib/ige_isb_api/request.rb', line 94 def initialize(params = {}) self.params = self.class::DEFAULT_PARAMS.merge(self.convert_symbols_to_strings(params)) self.validate_parameters # a bunch of stuff self.construct_request end |
Instance Attribute Details
#params ⇒ Object
Returns the value of attribute params.
12 13 14 |
# File 'lib/ige_isb_api/request.rb', line 12 def params @params end |
#request ⇒ Object
Returns the value of attribute request.
12 13 14 |
# File 'lib/ige_isb_api/request.rb', line 12 def request @request end |
Instance Method Details
#send ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/ige_isb_api/request.rb', line 102 def send uri = URI.parse(IGE_ISB_API::Constants::API_SERVER) http = Net::HTTP.new(uri.host, uri.port) # see http://www.rubyinside.com/nethttp-cheat-sheet-2940.html http.use_ssl = (uri.scheme === 'https') # http.cert = OpenSSL::X509::Certificate.new(pem) # http.key = OpenSSL::PKey::RSA.new(pem) # http.verify_mode = OpenSSL::SSL::VERIFY_PEER if IGE_ISB_API::Constants::DEBUGGING puts "DEBUGGING: http = #{http.inspect}" puts "DEBUGGING: self.request = #{self.request.inspect}" end return http.request(self.request) end |