Class: Elements::ApiV1

Inherits:
Api
  • Object
show all
Defined in:
lib/elements.rb

Overview

ApiV1 class uses the older v1 version of the elements Api

Class Method Summary collapse

Methods inherited from Api

add_forex_offer, add_user, buy_purchase_info, cancel_forex_offer, cancel_purchase_order, create_account, create_purchase_order, exchange_purchase_info, fetch_order_elements, find_account_name, find_active_forex_offer, find_balance, find_forex_offer_by_currency, find_forex_offer_by_external_key, find_forex_offer_by_id, find_or_create_forex_offer, find_purchase_order, find_user, process_purchase_order, save_order_elements, sell_purchase_info, set_account_balance

Class Method Details

.find_currenciesObject

Find Currencies is a class method that returns all the currencies added to Elements



343
344
345
# File 'lib/elements.rb', line 343

def self.find_currencies
  get_data('currency')
end

.find_currency(currency) ⇒ Object

Find currency is a class method that finds a particular currency depending on the currency name or elements_id



348
349
350
351
352
353
354
355
# File 'lib/elements.rb', line 348

def self.find_currency(currency)
  params = if(currency.elements_id.blank?)
    {"currency.name" => currency.vcx_name}
  else
    {"currency.id" => currency.elements_id}
  end
  get_data('currency', params) 
end

.update_user(user, ipaddress = '123.123.123.123') ⇒ Object

Update_user method updates the user information using elements API



331
332
333
334
335
336
337
338
339
340
# File 'lib/elements.rb', line 331

def self.update_user(user, ipaddress='123.123.123.123')
  params = {
    'user.id' =>  user.elements_id,
    'ipAddress' =>  ipaddress,
    'user.emailAddress' => user.email,
    'user.gender' =>       user.gender[0],
    'user.dateOfBirth' =>  user.dob.strftime("%Y/%m/%d")
  }
  post_data 'user/update', params
end