gcen-client 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5eacc47d1fbd10bda9bff24d9acd4dc8d8a1e53b
4
+ data.tar.gz: c0eb18035dfb0b7096d89ee0409bf8e8c145550a
5
+ SHA512:
6
+ metadata.gz: 157bed5b829fd15b9fc2c668e085f3741315d5a57263224fedb6948a2ecd3a89c5fd92d619e144c6c82f53a8bad3412f6a44150e8fb94da7645e2f320ee6d5ba
7
+ data.tar.gz: 636d928e4aa7f54c83de15d65b7ddfe0b7189c6fea6d03b6460d48cd3d0fa6b4c8f1eecf410f4f13e9857e70ce746c2c2b5c3dce379ca666d8364468ef83641b
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,26 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ gcen-client (0.1.0)
5
+ faraday_middleware (~> 0.10.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ faraday (0.14.0)
11
+ multipart-post (>= 1.2, < 3)
12
+ faraday_middleware (0.10.1)
13
+ faraday (>= 0.7.4, < 1.0)
14
+ multipart-post (2.0.0)
15
+ rake (10.5.0)
16
+
17
+ PLATFORMS
18
+ ruby
19
+
20
+ DEPENDENCIES
21
+ bundler (~> 1.16)
22
+ gcen-client!
23
+ rake (~> 10.0)
24
+
25
+ BUNDLED WITH
26
+ 1.16.1
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Dmitriy Strukov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,12 @@
1
+ # Gcen::Client
2
+
3
+ The `gcen-client` library provides access to the Gcen API from applications in the Ruby language. It
4
+ includes a pre-defined set of methods.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'gcen-client'
12
+ ```
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "gcen/client"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,30 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ require 'gcen/client/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'gcen-client'
9
+ spec.version = Gcen::Client::VERSION
10
+ spec.authors = ['Dmitriy Strukov']
11
+ spec.email = ['dmitiry_strukov2011@mail.ru']
12
+
13
+ spec.summary = 'GCEN API Client'
14
+ spec.description = 'GCEN API: Generic Investment API 0.1.1'
15
+ spec.homepage = 'http://github.com/evil-raccoon/gcen-client'
16
+ spec.license = 'MIT'
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
+ f.match(%r{^(test|spec|features)/})
20
+ end
21
+
22
+ spec.bindir = 'exe'
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ['lib']
25
+
26
+ spec.add_development_dependency 'bundler', '~> 1.16'
27
+ spec.add_development_dependency 'rake', '~> 10.0'
28
+
29
+ spec.add_dependency 'faraday_middleware', '~> 0.10.0'
30
+ end
@@ -0,0 +1,2 @@
1
+ require 'gcen/client/version'
2
+ require 'gcen/client/api'
@@ -0,0 +1,179 @@
1
+ require 'faraday'
2
+ require 'json'
3
+
4
+ module Gcen
5
+ module Client
6
+ class API
7
+ API_HOST = 'https://gcen.i-dash.co.uk/Api/'
8
+
9
+ attr_reader :gcen_token
10
+
11
+ # Authentication
12
+ #
13
+ # With each request, You must send an extra HTTP header, 'Authentication'
14
+ # We suggest using JSON as the data transfer type, hence you should set the Content Type to application/json
15
+ # All API requests must be made over HTTPS in POST format.
16
+ def initialize(gcen_token:)
17
+ @gcen_token = gcen_token
18
+ end
19
+
20
+ # AML Registration
21
+ # This method will register a client with GCEN
22
+ #
23
+ # @since 0.1.0
24
+ #
25
+ # @see https://app.gcen.co.uk/Api/AMLRegister
26
+ def aml_register(params:)
27
+ post_request('AMLRegister', params)
28
+ end
29
+
30
+ # GCS Balance
31
+ # This method will return the GCS balance for a given client's currency
32
+ #
33
+ # @since 0.1.0
34
+ #
35
+ # @see https://app.gcen.co.uk/Api/GCSBalance
36
+ def gcs_balance(client_id:, currency:)
37
+ post_request('GCSBalance', {
38
+ ClientId: client_id,
39
+ Currency: currency
40
+ })
41
+ end
42
+
43
+ # Bank transfer deposit
44
+ # Instructs GCEN of impending bank transfer deposit. Supplies the bank details and reference necessary.
45
+ #
46
+ # @since 0.1.0
47
+ #
48
+ # @see https://app.gcen.co.uk/Api/InvestmentDeposit
49
+ def investment_deposit(params:)
50
+ post_request('InvestmentDeposit', params)
51
+ end
52
+
53
+ # Card Payment Deposit
54
+ # Make an investment/deposit by credit/debit card.
55
+ #
56
+ # @since 0.1.0
57
+ #
58
+ # @see https://app.gcen.co.uk/Api/CardPayment
59
+ def card_payment(params:)
60
+ post_request('CardPayment', params)
61
+ end
62
+
63
+ # Check Card Payment Response
64
+ # This method checks whether a card payment was authorised and payment was successfully taken.
65
+ #
66
+ # @since 0.1.0
67
+ #
68
+ # @see https://app.gcen.co.uk/Api/CheckCardPaymentResponse
69
+ def check_card_payment_response(ref:, return_mac:)
70
+ post_request('CheckCardPaymentResponse', {
71
+ REF: ref,
72
+ RETURNMAC: return_mac
73
+ })
74
+ end
75
+
76
+ # Payment return from balance
77
+ # Instructs GCEN to make a payment out using one of the clients' GCS balances.
78
+ #
79
+ # @since 0.1.0
80
+ #
81
+ # @see https://app.gcen.co.uk/Api/PaymentReturnFromGCSBalance
82
+ def payment_return_from_gcs_balance(params:)
83
+ post_request('PaymentReturnFromGCSBalance', params)
84
+ end
85
+
86
+ # GCS Balance Transfer
87
+ # Instructs GCEN to move money from one GCS client balance to another. Internally, GCEN
88
+ # creates a virutal deal for the "FromClient". Money is moved from the "FromClient" balance to
89
+ # the virtual deal, and money is moved from the virutal deal to the "ToClient" balance.
90
+ #
91
+ # @since 0.1.0
92
+ #
93
+ # @see https://app.gcen.co.uk/Api/GCSBalanceTransfer
94
+ def gcs_balance_transfer(params:)
95
+ post_request('GCSBalanceTransfer', params)
96
+ end
97
+
98
+ # FX Quote
99
+ # Generates a unique quote from GCEN to exchange currency. Returns an FX Online Deal
100
+ # Quotation with a quotation reference. Quote is valid for purchase up to 30 minutes.
101
+ #
102
+ # @since 0.1.0
103
+ #
104
+ # @see https://app.gcen.co.uk/Api/GetFXQuote
105
+ def get_fx_quote(params:)
106
+ post_request('GetFXQuote', params)
107
+ end
108
+
109
+ # Confirm FX Quote - Card Payment
110
+ # This method confirms a given FX quote and sets up the payment system so the user can
111
+ # place their transaction.
112
+ #
113
+ # @since 0.1.0
114
+ #
115
+ # @see https://app.gcen.co.uk/Api/ConfirmQuoteWithCardPayment
116
+ def confirm_quote_with_card_payment(params:)
117
+ post_request('ConfirmQuoteWithCardPayment', params)
118
+ end
119
+
120
+ # Confirm FX Quote - Bank Transfer
121
+ # This method confirms a given FX quote and returns the amount and bank account that the
122
+ # client must pay in to.
123
+ #
124
+ # @since 0.1.0
125
+ #
126
+ # @see https://app.gcen.co.uk/Api/ConfirmQuoteWithBankTransfer
127
+ def confirm_quote_with_bank_transfer(params:)
128
+ post_request('ConfirmQuoteWithBankTransfer', params)
129
+ end
130
+
131
+ # Credit GCS Balance
132
+ # Makes a manual adjustment to a client's GCS balance.
133
+ #
134
+ # @since 0.1.0
135
+ #
136
+ # @see https://app.gcen.co.uk/Api/CreditGCSBalance
137
+ def credit_gcs_balance(client_id:, currency:, amount:)
138
+ post_request('CreditGCSBalance', {
139
+ ClientId: client_id,
140
+ Currency: currency,
141
+ Amount: amount
142
+ })
143
+ end
144
+
145
+ # Upload Documentation
146
+ # This method allows you to send GCEN the client's Id documents for them to verify and
147
+ # confirm the identity of the client.
148
+ #
149
+ # @since 0.1.0
150
+ #
151
+ # @see https://app.gcen.co.uk/Api/UploadIdDocuments
152
+ def upload_id_documents(client_id:, document_1:, document_2:)
153
+ post_request('UploadIdDocuments', {
154
+ ClientId: client_id,
155
+ Document1: document_1,
156
+ Document2: document_2
157
+ })
158
+ end
159
+
160
+ private
161
+
162
+ def post_request(endpoint_name, body, content_type='application/json')
163
+ http = Faraday.new(url: API_HOST) do |param|
164
+ param.headers['Authentication'] = gcen_token
165
+ param.adapter Faraday.default_adapter
166
+ end
167
+
168
+ response = http.post do |request|
169
+ request.url endpoint_name
170
+
171
+ request.body = body.to_json
172
+ request.headers['Content-Type'] = content_type
173
+ end
174
+
175
+ JSON.parse(response.body)
176
+ end
177
+ end
178
+ end
179
+ end
@@ -0,0 +1,5 @@
1
+ module Gcen
2
+ module Client
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gcen-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Dmitriy Strukov
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-02-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: faraday_middleware
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.10.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.10.0
55
+ description: 'GCEN API: Generic Investment API 0.1.1'
56
+ email:
57
+ - dmitiry_strukov2011@mail.ru
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - Gemfile.lock
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - bin/console
69
+ - bin/setup
70
+ - gcen-client.gemspec
71
+ - lib/gcen/client.rb
72
+ - lib/gcen/client/api.rb
73
+ - lib/gcen/client/version.rb
74
+ homepage: http://github.com/evil-raccoon/gcen-client
75
+ licenses:
76
+ - MIT
77
+ metadata: {}
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 2.6.8
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: GCEN API Client
98
+ test_files: []