Module: Wavecrest
- Defined in:
- lib/wavecrest.rb,
lib/wavecrest/version.rb,
lib/wavecrest/configuration.rb
Defined Under Namespace
Classes: Configuration
Constant Summary collapse
- VERSION =
"0.0.4"
Class Attribute Summary collapse
-
.auth_token ⇒ Object
Returns the value of attribute auth_token.
-
.auth_token_issued ⇒ Object
Returns the value of attribute auth_token_issued.
-
.configuration ⇒ Object
Returns the value of attribute configuration.
Class Method Summary collapse
- .activate(user_id, proxy, payload) ⇒ Object
- .auth ⇒ Object
- .auth_need? ⇒ Boolean
- .balance(user_id, proxy) ⇒ Object
- .cardholder(user_id, proxy) ⇒ Object
- .configure {|configuration| ... } ⇒ Object
- .countries ⇒ Object
- .details(user_id, proxy) ⇒ Object
- .load_money(user_id, proxy, params = {}) ⇒ Object
- .prefunding_account(currency = 'EUR') ⇒ Object
- .prefunding_accounts ⇒ Object
- .request_card(params) ⇒ Object
- .send_request(method, path, params = {}) ⇒ Object
- .transactions(user_id, proxy) ⇒ Object
- .update_status(user_id, proxy, payload) ⇒ Object
- .upload_docs(user_id, payload) ⇒ Object
Class Attribute Details
.auth_token ⇒ Object
Returns the value of attribute auth_token.
11 12 13 |
# File 'lib/wavecrest.rb', line 11 def auth_token @auth_token end |
.auth_token_issued ⇒ Object
Returns the value of attribute auth_token_issued.
11 12 13 |
# File 'lib/wavecrest.rb', line 11 def auth_token_issued @auth_token_issued end |
.configuration ⇒ Object
Returns the value of attribute configuration.
11 12 13 |
# File 'lib/wavecrest.rb', line 11 def configuration @configuration end |
Class Method Details
.activate(user_id, proxy, payload) ⇒ Object
127 128 129 |
# File 'lib/wavecrest.rb', line 127 def self.activate user_id, proxy, payload send_request :post, "/users/#{user_id}/cards/#{proxy}/activate", payload end |
.auth ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/wavecrest.rb', line 37 def self.auth url = configuration.endpoint + "/v3/services/authenticator" headers = { "DeveloperId" => configuration.user, "DeveloperPassword" => configuration.password, "X-Method-Override" => 'login', accept: :json, content_type: :json } RestClient.proxy = configuration.proxy if configuration.proxy request = RestClient::Request.new(method: :post, url: url, headers: headers) response = request.execute.body data = JSON.parse response self.auth_token = data["token"] self.auth_token_issued = Time.now end |
.auth_need? ⇒ Boolean
32 33 34 35 |
# File 'lib/wavecrest.rb', line 32 def self.auth_need? return true unless auth_token return true if auth_token_issued.kind_of?(Time) and auth_token_issued + 1.hour < Time.now end |
.balance(user_id, proxy) ⇒ Object
104 105 106 107 |
# File 'lib/wavecrest.rb', line 104 def self.balance user_id, proxy resp = send_request :get, "/users/#{user_id}/cards/#{proxy}/balance" resp['avlBal'].to_i end |
.cardholder(user_id, proxy) ⇒ Object
131 132 133 |
# File 'lib/wavecrest.rb', line 131 def self.cardholder user_id, proxy send_request :get, "/users/#{user_id}/cards/#{proxy}/cardholderinfo" end |
.configure {|configuration| ... } ⇒ Object
14 15 16 17 |
# File 'lib/wavecrest.rb', line 14 def self.configure self.configuration ||= Wavecrest::Configuration.new yield(configuration) end |
.countries ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/wavecrest.rb', line 19 def self.countries [ 'AX', 'AL', 'AD', 'AI', 'AG', 'AR', 'AM', 'AW', 'AU', 'AT', 'BS', 'BH', 'BB', 'BY', 'BE', 'BZ', 'BM', 'BT', 'BQ', 'BA', 'BR', 'BN', 'BG', 'CA', 'CV', 'KY', 'CL', 'CN', 'CO', 'CR', 'HR', 'CW', 'CY', 'CZ', 'DK', 'DM', 'DO', 'EC', 'SV', 'EE', 'FK', 'FO', 'FI', 'FR', 'GF', 'GE', 'DE', 'GI', 'GR', 'GL', 'GD', 'GP', 'GT', 'GG', 'GY', 'HK', 'HU', 'IS', 'ID', 'IE', 'IM', 'IL', 'IT', 'JM', 'JP', 'JE', 'JO', 'KZ', 'KR', 'XK', 'KW', 'LV', 'LI', 'LT', 'LU', 'MK', 'MY', 'MV', 'MT', 'MQ', 'MU', 'YT', 'MX', 'MD', 'MC', 'MN', 'ME', 'MA', 'NP', 'NL', 'NZ', 'NI', 'NO', 'OM', 'PA', 'PG', 'PY', 'PE', 'PH', 'PL', 'PT', 'QA', 'RE', 'RO', 'RU', 'BL', 'KN', 'LC', 'MF', 'VC', 'SM', 'SA', 'RS', 'SC', 'SG', 'SX', 'SK', 'SI', 'ZA', 'ES', 'SR', 'SE', 'CH', 'TW', 'TH', 'TT', 'TR', 'TC', 'UA', 'AE', 'GB', 'UY', 'VE', 'VG' ] end |
.details(user_id, proxy) ⇒ Object
110 111 112 |
# File 'lib/wavecrest.rb', line 110 def self.details user_id, proxy send_request :get, "/users/#{user_id}/cards/#{proxy}/carddetails" end |
.load_money(user_id, proxy, params = {}) ⇒ Object
95 96 97 98 99 100 101 102 |
# File 'lib/wavecrest.rb', line 95 def self.load_money(user_id, proxy, params= {}) default_params = { "channelType" => "1", "agentId" => configuration.partner_id } payload = default_params.merge params send_request :post, "/users/#{user_id}/cards/#{proxy}/load", payload end |
.prefunding_account(currency = 'EUR') ⇒ Object
118 119 120 |
# File 'lib/wavecrest.rb', line 118 def self.prefunding_account(currency='EUR') send_request :post, "/businesspartners/#{configuration.partner_id}/balance", currency: currency end |
.prefunding_accounts ⇒ Object
122 123 124 125 |
# File 'lib/wavecrest.rb', line 122 def self.prefunding_accounts resp = send_request :get, "/businesspartners/#{configuration.partner_id}/txnaccounts" resp['txnAccountList'] end |
.request_card(params) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/wavecrest.rb', line 83 def self.request_card(params) default_params = { "cardProgramId" => "0", "Businesspartnerid" => configuration.partner_id, "channelType" => "1", # "deliveryType" => 'Standard Delivery Type', "localeTime" => Time.now } payload = default_params.merge params send_request :post, "/cards", payload end |
.send_request(method, path, params = {}) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/wavecrest.rb', line 57 def self.send_request method, path, params={} auth if auth_need? url = configuration.endpoint + "/v3/services" + path payload = params.to_json headers = { "DeveloperId" => configuration.user, "DeveloperPassword" => configuration.password, "AuthenticationToken" => auth_token, accept: :json, content_type: :json } begin RestClient.proxy = configuration.proxy if configuration.proxy request = RestClient::Request.new(method: method, url: url, payload: payload, headers: headers) response = request.execute.body RestClient.proxy = nil JSON.parse response rescue => e puts e., e.response return JSON.parse e.response end end |
.transactions(user_id, proxy) ⇒ Object
114 115 116 |
# File 'lib/wavecrest.rb', line 114 def self.transactions user_id, proxy send_request :post, "/users/#{user_id}/cards/#{proxy}/transactions", txnCount: 10000 end |
.update_status(user_id, proxy, payload) ⇒ Object
139 140 141 |
# File 'lib/wavecrest.rb', line 139 def self.update_status user_id, proxy, payload send_request :post, "/users/#{user_id}/cards/#{proxy}/status", payload end |
.upload_docs(user_id, payload) ⇒ Object
135 136 137 |
# File 'lib/wavecrest.rb', line 135 def self.upload_docs user_id, payload send_request :post, "/users/#{user_id}/kyc", payload end |