Module: CoinsPaid::API

Defined in:
lib/coins_paid/api.rb,
lib/coins_paid/api/types.rb,
lib/coins_paid/api/currency.rb,
lib/coins_paid/api/requester.rb,
lib/coins_paid/api/signature.rb,
lib/coins_paid/api/transport.rb,
lib/coins_paid/api/withdrawal.rb,
lib/coins_paid/api/take_address.rb,
lib/coins_paid/api/callback_data.rb,
lib/coins_paid/api/currencies_list.rb

Defined Under Namespace

Modules: CurrenciesList, Requester, Signature, Transport, Types Classes: CallbackData, Currency, TakeAddress, Withdrawal

Constant Summary collapse

Error =
Class.new RuntimeError
ProcessingError =
Class.new Error
ConnectionError =
Class.new Error
InvalidSignatureError =
Class.new Error
URL =
'https://app.coinspaid.com/api/v2/'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.public_keyObject

Returns the value of attribute public_key.



27
28
29
# File 'lib/coins_paid/api.rb', line 27

def public_key
  @public_key
end

.secret_keyObject

Returns the value of attribute secret_key.



28
29
30
# File 'lib/coins_paid/api.rb', line 28

def secret_key
  @secret_key
end

Class Method Details

.callback(request_body, headers) ⇒ Object



53
54
55
56
57
58
59
60
61
# File 'lib/coins_paid/api.rb', line 53

def callback(request_body, headers)
  Signature.check!(
    request_body: request_body,
    key: headers['X-Processing-Key'],
    signature: headers['X-Processing-Signature']
  )

  CallbackData.from_json(JSON.parse(request_body, symbolize_names: true))
end

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



34
35
36
# File 'lib/coins_paid/api.rb', line 34

def configure
  yield self
end

.currencies_listObject



49
50
51
# File 'lib/coins_paid/api.rb', line 49

def currencies_list
  CurrenciesList.call
end

.take_address(foreign_id:, currency:, convert_to: nil) ⇒ Object



38
39
40
41
42
43
# File 'lib/coins_paid/api.rb', line 38

def take_address(foreign_id:, currency:, convert_to: nil)
  Requester.call(
    TakeAddress,
    foreign_id: foreign_id, currency: currency, convert_to: convert_to
  )
end

.withdraw(data) ⇒ Object



45
46
47
# File 'lib/coins_paid/api.rb', line 45

def withdraw(data)
  Requester.call(Withdrawal, data)
end