Class: IGE_ISB_API::Bonus

Inherits:
Object
  • Object
show all
Defined in:
lib/ige_isb_api/bonus.rb

Constant Summary collapse

DEFAULT_PARAMS =
{
  'api_key' => IGE_ISB_API::Constants::BONUS_API_KEY
}
COMMON_FIELDS =
{
  'api_key' => {:required => true, :type => 'string', :length => 128}
}
COMMANDS =
{
  'get_trigger_bonus' => {
    'login' => {:required => true, :type => 'username', :length => 32},
    'trigger' => {required: true, type: 'string', values: ['sign up', 'deposit', 'promotion code']},
    'transaction_ref' => {required: false, type: 'string', length: 128}
  },
  'get_client_bonuses' => {
    'login' => {:required => true, :type => 'username', :length => 32},
    'statuses' => {required: false, type: 'string',
                  values: IGE_ISB_API::Constants::ALLOWED_BONUS_STATUSES},
    'types' => {required: false, type: 'string',
                  values: IGE_ISB_API::Constants::ALLOWED_BONUS_TYPES},
    'cartecs' => {required: false, type: 'string', length: 255},
    'start_date' => {required: false, type: 'date'},
    'end_date' => {required: false, type: 'date'},
    'start' => {required: false, type: 'int'},
    'results_per_page' => {required: false, type: 'int'},
    'order_by_field' => {required: false, type: 'string', values: [
      'cartec', 'bonus_initial_value', 'bonus_current_value', 'bonus_state',
      'bonus_type', 'issue_date', 'expiration_date', 'bonus_finish_date',
      'issued_by', 'total_bet', 'name'
    ]},
    'order_by_dir' => {required: false, type: 'string', values: ['ASC', 'DESC']},
    'include_expired' => {required: false, type: 'boolint'},
    'only_expired' => {required: false, type: 'boolint'}
  },
  'count_client_bonuses' => {
    'login' => {required: true, type: 'username'},
    'statuses' => {required: false, type: 'string',
                  values: IGE_ISB_API::Constants::ALLOWED_BONUS_STATUSES},
    'types' => {required: false, type: 'string',
                  values: IGE_ISB_API::Constants::ALLOWED_BONUS_TYPES},
    'cartecs' => {required: false, type: 'string', length: 255},
    'start_date' => {required: false, type: 'date'},
    'end_date' => {required: false, type: 'date'},
    'include_expired' => {required: false, type: 'boolint'},
    'only_expired' => {required: false, type: 'boolint'}
  },
  'has_pending_offers' => {
    'login' => {required: true, type: 'username'},
  },
  'accept_bonus' => {
    'login' => {required: true, type: 'username'},
    'id' => {required: true, type: 'int'},
    'nonce' => {required: false, type: 'string'}
  },
  'decline_bonus' => {
    'login' => {required: true, type: 'username'},
    'id' => {required: true, type: 'int'},
    'nonce' => {required: false, type: 'string'}
  },
  'get_remaining_playthrough' => {
    'login' => {required: true, type: 'username'},
    'nonce' => {required: false, type: 'string'}
  },
  'remove_bonus_and_winnings_on_withdraw' => {
    'login' => {required: true, type: 'username'},
    'nonce' => {required: false, type: 'string'}
  },
  'issue_bonus' => {
    'login' => {required: true, type: 'username'},
    'id_template' => {required: false, type: 'int'},
    'promo' => {required: false, type: 'string'},
    'location' => {required: false, type: 'string', values: ['cert', 'certd']},
    'nonce' => {required: false, type: 'string'}
  },
  'cancel_bonus' => {
    'login' => {required: true, type: 'username'},
    'id_template' => {required: false, type: 'int'},
    'comment' => {required: false, type: 'string'},
    'nonce' => {required: false, type: 'string'}
  },
  'reset_bonus' => {
    'login' => {required: true, type: 'username'},
    'nonce' => {required: false, type: 'string'}
  },
  'update_active_balance_current_value' => {
    'login' => {required: true, type: 'username'},
    'deposit' => {required: true, type: 'currency'},
    'nonce' => {required: false, type: 'string'}
  },
  'assign_certificate_to_player' => {
    'email' => {required: true, type: 'email', length: 50},
    'certificate_name' => {required: true, type: 'string'},
    'nonce' => {required: false, type: 'string'}
  },
  'bonus_vip_points' => {
    'login' => {required: true, type: 'username'},
    'amount' => {required: true, type: 'currency'},
    'reason' => {required: false, type: 'string'},
    'name' => {required: true, type: 'string'},
    'nonce' => {required: false, type: 'string'}
  },
  'generate_certificate' => {
    'template_certificate_id' => {required: true, type: 'int'},
    'nonce' => {required: false, type: 'string'}
  },
  'generate_bulk_certificates' => {
    'template_certificate_id' => {required: true, type: 'int'},
    'count' => {required: true, type: 'int'},
    'certificate_value' => {required: false, type: 'currency'},
    'nonce' => {required: false, type: 'string'}
  },
  'generate_player_assigned_certificate' => {
    'login' => {required: true, type: 'username'},
    'template_certificate_id' => {required: true, type: 'int'},
    'certificate_value' => {required: false, type: 'currency'},
    'nonce' => {required: false, type: 'string'}
  },
  'get_template_id_by_name' => {
    'name' => {required: true, type: 'string'}
  },
  'count_promo_codes' => {
    'login' => {required: true, type: 'username'},
    'start_date' => {required: true, type: 'timestamp'},
    'end_date' => {required: true, type: 'timestamp'}
  },
  'sum_bonuses' => {
    'login' => {required: true, type: 'username'},
    'casino_prefix' => {required: false, type: 'string'}
  },
  'get_player_assigned_certificates' => {
    'login' => {required: true, type: 'username'},
    'promotion_code' => {required: false, type: 'string'},
    'template_certificate_ids' => {required: false, type: 'string'},
    'start_date' => {required: false, type: 'date'},
    'end_date' => {required: false, type: 'date'}
  },
  'delete_player_assigned_certificate' => {
    'login' => {required: true, type: 'username'},
    'promotion_code' => {required: true, type: 'string'},
    'nonce' => {required: false, type: 'string'}
  },
  'delete_generated_certificate' => {
    'promotion_code' => {required: true, type: 'string'},
    'nonce' => {required: false, type: 'string'}
  },
  'certificate_exists' => {
    'promotion_code' => {required: true, type: 'string'}
  },
  'allow_withdrawal' => {
    'login' => {required: true, type: 'username'}
  },
  'is_transaction_used' => {
    'login' => {required: true, type: 'username'},
    'transaction' => {required: true, type: 'string'}
  },
  'get_max_withdrawal' => {
    'login' => {required: true, type: 'username'}
  },
  'issue_remote_bonus' => {
    'login' => {required: true, type: 'username'},
    'id_template' => {required: true, type: 'int'},
    'amount' => {required: false, type: 'currency'},
    'nonce' => {required: false, type: 'string'}
  },
  'issue_batch_remote_bonus' => {
    'data' => {required: true, type: 'array'},
    'nonce' => {required: false, type: 'string'}
  },
  'get_templates_info' => {
    'type' => {required: true, type: 'string', values: ['manual', 'automatic', 'remote']},
    'status' => {required: true, type: 'string', values: ['active', 'inactive', 'deleted']},
    'trigger' => {required: true, type: 'string', values: ['sign up', 'deposit', 'promotion code']}
  },
  'redeem_threshold' => {
    'login' => {required: true, type: 'username'},
    'nonce' => {required: false, type: 'string'}
  },
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command, params = {}) ⇒ Bonus

Returns a new instance of Bonus.



195
196
197
198
199
200
201
202
# File 'lib/ige_isb_api/bonus.rb', line 195

def initialize(command, params = {})
  self.command = command
  self.params = self.class::DEFAULT_PARAMS.merge(self.convert_symbols_to_strings(params))
  self.validate_parameters
  # a bunch of stuff
  self.sign
  self.construct_request
end

Instance Attribute Details

#commandObject

Returns the value of attribute command.



14
15
16
# File 'lib/ige_isb_api/bonus.rb', line 14

def command
  @command
end

#paramsObject

Returns the value of attribute params.



14
15
16
# File 'lib/ige_isb_api/bonus.rb', line 14

def params
  @params
end

#requestObject

Returns the value of attribute request.



14
15
16
# File 'lib/ige_isb_api/bonus.rb', line 14

def request
  @request
end

Instance Method Details

#sendObject



204
205
206
207
208
209
210
211
212
213
214
215
216
217
# File 'lib/ige_isb_api/bonus.rb', line 204

def send
  uri = URI.parse(IGE_ISB_API::Constants::BONUS_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