lazerpay 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/lazerpay/agent.rb +35 -0
- data/lib/lazerpay/api_module.rb +3 -0
- data/lib/lazerpay/main_module.rb +141 -0
- data/lib/lazerpay.rb +40 -0
- metadata +75 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8aed6c64257017df1f8d3e89304d75daabd525e7c29bbf78910bf9f2071e8ee5
|
4
|
+
data.tar.gz: 0644426e62305b0ad2cfe3037066800a3daf07b869ea189eaf7a75c19da87155
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3b4025bf7e5b9aa7394020f36eb452636cc751002ac328b17bb36feb93e0c34070e91c8cd553f70745e2ef9a874cd5028f4a3741d4276b1549c8a4c344278dfd
|
7
|
+
data.tar.gz: 13f62b404dcaf6140f91318f084af0c2d72bfc558cafb22b9c706cb86cedefbfd0a9559e45ed27d789ad76fea724542ba079b42e5c1a80e39dc64977f76c9567
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "httparty"
|
2
|
+
require_relative "api_module.rb"
|
3
|
+
class Agent
|
4
|
+
|
5
|
+
def self.post endpoint, payload
|
6
|
+
|
7
|
+
sk = payload[:secret_key];
|
8
|
+
pk = payload[:public_key];
|
9
|
+
data = payload[:data];
|
10
|
+
|
11
|
+
response = HTTParty.post("#{API::BASE_URL}#{endpoint}",
|
12
|
+
:body => data.to_json,
|
13
|
+
:headers => { "Authorization"=> "Bearer #{sk}", "X-api-key" => pk, "content-type" => "application/json"})
|
14
|
+
return response
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.get endpoint, payload
|
19
|
+
|
20
|
+
sk = payload[:secret_key];
|
21
|
+
pk = payload[:public_key];
|
22
|
+
rp = payload[:route_parameter];
|
23
|
+
qp = payload[:query_parameter];
|
24
|
+
|
25
|
+
url = rp.nil? ? "#{API::BASE_URL}#{endpoint}" : "#{API::BASE_URL}#{endpoint}/#{rp}"
|
26
|
+
|
27
|
+
url = qp.nil? ? "#{API::BASE_URL}#{endpoint}" : "#{API::BASE_URL}#{endpoint}?#{qp}" if rp.nil?
|
28
|
+
|
29
|
+
puts url
|
30
|
+
|
31
|
+
response = HTTParty.get(url,
|
32
|
+
:headers => { "Authorization"=> "Bearer #{sk}", "X-api-key" => pk, "content-type" => "application/json"})
|
33
|
+
return response
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
require_relative "agent.rb";
|
2
|
+
module LazerPayModule
|
3
|
+
|
4
|
+
class Wrapper
|
5
|
+
@@sk = nil;
|
6
|
+
@@pk = nil;
|
7
|
+
|
8
|
+
def initialize public_key, secret_key
|
9
|
+
@@pk = public_key;
|
10
|
+
@@sk = secret_key;
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
class Payment < Wrapper
|
17
|
+
|
18
|
+
def initialize; end
|
19
|
+
|
20
|
+
def init payload
|
21
|
+
response = Agent.post( "/transaction/initialize", { secret_key: @@sk, public_key: @@pk, data: payload } );
|
22
|
+
|
23
|
+
return response.to_h;
|
24
|
+
end
|
25
|
+
|
26
|
+
def verify reference
|
27
|
+
response = Agent.get( "/transaction/verify", { secret_key: @@sk, public_key: @@pk, route_parameter: reference } );
|
28
|
+
|
29
|
+
return response.to_h;
|
30
|
+
end
|
31
|
+
|
32
|
+
def get_standard_link payload
|
33
|
+
response = Agent.post( "/payment_links/standard", { secret_key: @@sk, public_key: @@pk, data: payload } );
|
34
|
+
|
35
|
+
return response.to_h;
|
36
|
+
end
|
37
|
+
|
38
|
+
def get_donation_link payload
|
39
|
+
response = Agent.post( "/payment_links/donation", { secret_key: @@sk, public_key: @@pk, data: payload } );
|
40
|
+
|
41
|
+
return response.to_h;
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
class Payout < Wrapper
|
47
|
+
|
48
|
+
def initialize; end
|
49
|
+
|
50
|
+
def crypto payload
|
51
|
+
response = Agent.post( "/crypto/payouts/initiate", { secret_key: @@sk, public_key: @@pk, data: payload } );
|
52
|
+
|
53
|
+
return response.to_h;
|
54
|
+
end
|
55
|
+
|
56
|
+
def bank payload
|
57
|
+
response = Agent.post( "/bank/payouts", { secret_key: @@sk, public_key: @@pk, data: payload } );
|
58
|
+
|
59
|
+
return response.to_h;
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
module Deposit
|
65
|
+
|
66
|
+
class FIAT < Wrapper
|
67
|
+
|
68
|
+
def initialize; end
|
69
|
+
|
70
|
+
def init payload
|
71
|
+
response = Agent.post( "/bank/funding/initiate", { secret_key: @@sk, public_key: @@pk, data: payload } );
|
72
|
+
|
73
|
+
return response.to_h;
|
74
|
+
end
|
75
|
+
|
76
|
+
def get_funding_rate currency
|
77
|
+
response = Agent.get( "/bank/funding/rate", { secret_key: @@sk, public_key: @@pk, query_parameter: "currency=#{currency}" } );
|
78
|
+
|
79
|
+
return response.to_h;
|
80
|
+
end
|
81
|
+
|
82
|
+
def get_available_accounts
|
83
|
+
response = Agent.get( "/bank/funding/accounts", { secret_key: @@sk, public_key: @@pk } );
|
84
|
+
|
85
|
+
return response.to_h;
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
class CRYPTO < Wrapper
|
91
|
+
|
92
|
+
def initialize; end
|
93
|
+
|
94
|
+
def get_wallet_address coin
|
95
|
+
response = Agent.get( "/crypto/funding/address", { secret_key: @@sk, public_key: @@pk, query_parameter: "coin=#{coin}" } );
|
96
|
+
|
97
|
+
return response.to_h;
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
class Swap < Wrapper
|
107
|
+
|
108
|
+
def initialize; end
|
109
|
+
|
110
|
+
def init payload
|
111
|
+
response = Agent.post( "/swap/crypto", { secret_key: @@sk, public_key: @@pk, data: payload } );
|
112
|
+
|
113
|
+
return response.to_h;
|
114
|
+
end
|
115
|
+
|
116
|
+
def get_swap_amount payload
|
117
|
+
response = Agent.post( "/swap/crypto/amount-out", { secret_key: @@sk, public_key: @@pk, data: payload } );
|
118
|
+
|
119
|
+
return response.to_h;
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
class Transaction < Wrapper
|
126
|
+
|
127
|
+
def initialize; end
|
128
|
+
|
129
|
+
def get transaction_id
|
130
|
+
response = Agent.get( "/transactions", { secret_key: @@sk, public_key: @@pk, route_parameter: transaction_id } );
|
131
|
+
|
132
|
+
return response.to_h;
|
133
|
+
end
|
134
|
+
|
135
|
+
def get_all
|
136
|
+
response = Agent.get( "/transactions", { secret_key: @@sk, public_key: @@pk } );
|
137
|
+
|
138
|
+
return response.to_h;
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
data/lib/lazerpay.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require_relative "./lazerpay/main_module.rb";
|
2
|
+
require "dotenv/load"
|
3
|
+
|
4
|
+
class LazerPay
|
5
|
+
attr_accessor :secret_key, :public_key, :payment, :fiat_deposit, :crypto_deposit, :payout, :crypto_swap, :transaction
|
6
|
+
|
7
|
+
def initialize public_key = nil, secret_key = nil
|
8
|
+
@secret_key = secret_key;
|
9
|
+
@public_key = public_key;
|
10
|
+
|
11
|
+
# Error Handling
|
12
|
+
|
13
|
+
raise "Public key cannot be undefined" if @public_key.nil?
|
14
|
+
|
15
|
+
raise "Secret key cannot be undefined" if @secret_key.nil?
|
16
|
+
|
17
|
+
raise "Invalid format for Public key, it must with 'pk'" unless @public_key.start_with?("pk_")
|
18
|
+
|
19
|
+
raise "Invalid format for Secret key, it must with 'sk'" unless @secret_key.start_with?("sk_")
|
20
|
+
|
21
|
+
# Loads public and private key in to sub-classes
|
22
|
+
LazerPayModule::Wrapper.new( @public_key, @secret_key )
|
23
|
+
|
24
|
+
@payment = LazerPayModule::Payment.new;
|
25
|
+
|
26
|
+
@payout = LazerPayModule::Payout.new;
|
27
|
+
|
28
|
+
@fiat_deposit = LazerPayModule::Deposit::FIAT.new;
|
29
|
+
|
30
|
+
@crypto_deposit = LazerPayModule::Deposit::CRYPTO.new;
|
31
|
+
|
32
|
+
@crypto_swap = LazerPayModule::Swap.new;
|
33
|
+
|
34
|
+
@transaction = LazerPayModule::Transaction.new;
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
lp = LazerPay.new(ENV["LP_PK"], ENV["LP_SK"]);
|
40
|
+
|
metadata
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lazerpay
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Owoade Anuoluwapo
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-02-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '10.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '10.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: httparty
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.21.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.21.0
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
- owoadeanuoluwapo2@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- lib/lazerpay.rb
|
49
|
+
- lib/lazerpay/agent.rb
|
50
|
+
- lib/lazerpay/api_module.rb
|
51
|
+
- lib/lazerpay/main_module.rb
|
52
|
+
homepage: https://github.com/Owoade/lazerpay-ruby-sdk
|
53
|
+
licenses:
|
54
|
+
- MIT
|
55
|
+
metadata: {}
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options: []
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 2.0.0
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
requirements: []
|
71
|
+
rubygems_version: 3.3.7
|
72
|
+
signing_key:
|
73
|
+
specification_version: 4
|
74
|
+
summary: Ruby SDK for Lazerpay finance
|
75
|
+
test_files: []
|