cryptoprocessing 0.6.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.
Files changed (67) hide show
  1. checksums.yaml +7 -0
  2. data/.codeclimate.yml +35 -0
  3. data/.coveralls.yml +1 -0
  4. data/.document +5 -0
  5. data/.editorconfig +12 -0
  6. data/.gemtest +0 -0
  7. data/.gitattributes +1 -0
  8. data/.gitignore +129 -0
  9. data/.hound.yml +5 -0
  10. data/.rspec +3 -0
  11. data/.rubocop.yml +65 -0
  12. data/.rubocop_todo.yml +0 -0
  13. data/.ruby-version +1 -0
  14. data/.simplecov +8 -0
  15. data/.travis.yml +11 -0
  16. data/.yardopts +10 -0
  17. data/CHANGELOG.md +12 -0
  18. data/CODE_OF_CONDUCT.md +74 -0
  19. data/Gemfile +6 -0
  20. data/Gemfile.lock +94 -0
  21. data/LICENSE.txt +21 -0
  22. data/NOTICE.txt +2 -0
  23. data/README.md +86 -0
  24. data/Rakefile +21 -0
  25. data/VERSION +1 -0
  26. data/bin/console +14 -0
  27. data/bin/setup +8 -0
  28. data/cryptoprocessing.gemspec +39 -0
  29. data/exe/cryptoprocessing +5 -0
  30. data/lib/cryptoprocessing.rb +37 -0
  31. data/lib/cryptoprocessing/adapters/em_http.rb +71 -0
  32. data/lib/cryptoprocessing/adapters/net_http.rb +6 -0
  33. data/lib/cryptoprocessing/authentication.rb +67 -0
  34. data/lib/cryptoprocessing/authentication/storages/file_token_store.rb +0 -0
  35. data/lib/cryptoprocessing/authentication/storages/redis_token_store.rb +0 -0
  36. data/lib/cryptoprocessing/authentication/token_store.rb +57 -0
  37. data/lib/cryptoprocessing/cli.rb +203 -0
  38. data/lib/cryptoprocessing/client.rb +108 -0
  39. data/lib/cryptoprocessing/client/accounts.rb +43 -0
  40. data/lib/cryptoprocessing/client/addresses.rb +56 -0
  41. data/lib/cryptoprocessing/client/api_errors.rb +7 -0
  42. data/lib/cryptoprocessing/client/api_response.rb +39 -0
  43. data/lib/cryptoprocessing/client/callbacks.rb +39 -0
  44. data/lib/cryptoprocessing/client/coinbase_wallet.rb +45 -0
  45. data/lib/cryptoprocessing/client/net_response.rb +100 -0
  46. data/lib/cryptoprocessing/client/trackers.rb +37 -0
  47. data/lib/cryptoprocessing/client/transactions.rb +90 -0
  48. data/lib/cryptoprocessing/configurable.rb +73 -0
  49. data/lib/cryptoprocessing/connection.rb +140 -0
  50. data/lib/cryptoprocessing/default.rb +78 -0
  51. data/lib/cryptoprocessing/error.rb +3 -0
  52. data/lib/cryptoprocessing/models/account.rb +39 -0
  53. data/lib/cryptoprocessing/models/address.rb +17 -0
  54. data/lib/cryptoprocessing/models/api_object.rb +14 -0
  55. data/lib/cryptoprocessing/models/callback.rb +4 -0
  56. data/lib/cryptoprocessing/models/tracker.rb +4 -0
  57. data/lib/cryptoprocessing/models/transaction.rb +6 -0
  58. data/lib/cryptoprocessing/models/user.rb +6 -0
  59. data/lib/cryptoprocessing/rails.rb +13 -0
  60. data/lib/cryptoprocessing/version.rb +17 -0
  61. data/script/bootstrap +5 -0
  62. data/script/cibuild +5 -0
  63. data/script/console +11 -0
  64. data/script/package +7 -0
  65. data/script/release +16 -0
  66. data/script/test +17 -0
  67. metadata +236 -0
@@ -0,0 +1,78 @@
1
+ require 'cryptoprocessing/version'
2
+
3
+ module Cryptoprocessing
4
+ module Default
5
+ # Default API endpoint
6
+ API_ENDPOINT = 'https://api.cryptoprocessing.io'.freeze
7
+
8
+ # Default API namespace (suffix)
9
+ API_NAMESPACE = '/api'.freeze
10
+
11
+ BLOCKCHAIN_TYPE = 'btc'.freeze
12
+
13
+ # Default User Agent header string
14
+ USER_AGENT = "cryproprocessing/ruby/#{Cryptoprocessing::VERSION}".freeze
15
+
16
+ class << self
17
+
18
+ # Configuration options
19
+ # @return [Hash]
20
+ def options
21
+ Hash[Cryptoprocessing::Configurable.keys.map{|key| [key, send(key)]}]
22
+ end
23
+
24
+ # Default access token from ENV
25
+ # @return [String]
26
+ def access_token
27
+ ENV['CRYPTOPROCESSING_ACCESS_TOKEN']
28
+ end
29
+
30
+ # Default API endpoint from ENV or {API_ENDPOINT}
31
+ # @return [String]
32
+ def api_endpoint
33
+ ENV['CRYPTOPROCESSING_API_ENDPOINT'] || API_ENDPOINT
34
+ end
35
+
36
+ # Default API namespace from ENV or {API_NAMESPACE}
37
+ # @return [String]
38
+ def api_namespace
39
+ ENV['CRYPTOPROCESSING_API_NAMESPACE'] || API_NAMESPACE
40
+ end
41
+
42
+ def blockchain_type
43
+ ENV['CRYPTOPROCESSING_BLOCKCHAIN_TYPE'] || BLOCKCHAIN_TYPE
44
+ end
45
+
46
+ # Default Cryptoprocessing email for Auth from ENV
47
+ # @return [String]
48
+ def email
49
+ ENV['CRYPTOPROCESSING_EMAIL']
50
+ end
51
+
52
+ # Default Cryptoprocessing password for Auth from ENV
53
+ # @return [String]
54
+ def password
55
+ ENV['CRYPTOPROCESSING_PASSWORD']
56
+ end
57
+
58
+ # Default User-Agent header string from ENV or {USER_AGENT}
59
+ # @return [String]
60
+ def user_agent
61
+ ENV['CRYPTOPROCESSING_USER_AGENT'] || USER_AGENT
62
+ end
63
+
64
+ # Default behavior for reading .netrc file
65
+ # @return [Boolean]
66
+ def netrc
67
+ ENV['CRYPTOPROCESSING_NETRC'] || false
68
+ end
69
+
70
+ # Default path for .netrc file
71
+ # @return [String]
72
+ def netrc_file
73
+ ENV['CRYPTOPROCESSING_NETRC_FILE'] || File.join(ENV['HOME'].to_s, '.netrc')
74
+ end
75
+ end
76
+
77
+ end
78
+ end
@@ -0,0 +1,3 @@
1
+ module Cryptoprocessing
2
+
3
+ end
@@ -0,0 +1,39 @@
1
+ require 'cryptoprocessing/models/api_object'
2
+
3
+ module Cryptoprocessing
4
+ class Account < APIObject
5
+ # Create address
6
+ def create_address(options = {})
7
+ agent.create_address(self['id'], options) do |resp|
8
+ yield(data, resp) if block_given?
9
+ end
10
+ end
11
+
12
+ # List of transactions
13
+ def transactions(options = {})
14
+ agent.transactions(self['id'], options) do |data, resp|
15
+ yield(data, resp) if block_given?
16
+ end
17
+ end
18
+
19
+ # List of transactions by address
20
+ def transactions_by_address(address, options = {})
21
+ agent.transactions_by_address(self['id'], address, options) do |data, resp|
22
+ yield(data, resp) if block_given?
23
+ end
24
+ end
25
+
26
+ # Create transaction
27
+ def create_transaction(options = {})
28
+ agent.create_transaction(self['id'], options) do |data, resp|
29
+ yield(data, resp) if block_given?
30
+ end
31
+ end
32
+
33
+ def create_callback(address, options = {})
34
+ agent.create_callback(self['id'], address, options) do |data, resp|
35
+ yield(data, resp) if block_given?
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,17 @@
1
+ require 'cryptoprocessing/models/api_object'
2
+
3
+ module Cryptoprocessing
4
+ class Address < APIObject
5
+ def transactions(options = {})
6
+ agent.transactions_by_address(self['account_id'], self['address'], options) do |data, resp|
7
+ yield(data, resp) if block_given?
8
+ end
9
+ end
10
+
11
+ def create_transaction(to_address, amount, options = {})
12
+ agent.create_transaction(self['account_id'], self['address'], to_address, amount, options) do |data, resp|
13
+ yield(data, resp) if block_given?
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,14 @@
1
+ module Cryptoprocessing
2
+ class APIObject < Hash
3
+ def initialize(client, data)
4
+ super()
5
+ update(data)
6
+ @client = client
7
+ end
8
+
9
+ def update(data)
10
+ return if data.nil?
11
+ data.each {|key, val| self[key] = val} if data.is_a?(Hash)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,4 @@
1
+ module Cryptoprocessing
2
+ class Callback < APIObject
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Cryptoprocessing
2
+ class Tracker < APIObject
3
+ end
4
+ end
@@ -0,0 +1,6 @@
1
+ require 'cryptoprocessing/models/api_object'
2
+
3
+ module Cryptoprocessing
4
+ class Transaction < APIObject
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ require 'cryptoprocessing/models/api_object'
2
+
3
+ module Cryptoprocessing
4
+ class User < APIObject
5
+ end
6
+ end
@@ -0,0 +1,13 @@
1
+ module Cryptoprocessing
2
+ class Rails < ::Rails::Engine
3
+ config.after_initialize do
4
+ secrets = ::Rails.application.secrets
5
+ if defined?(secrets.cryptoprocessing_api_endpoint)
6
+ Cryptoprocessing.api_endpoint = secrets.cryptoprocessing_api_endpoint
7
+ end
8
+ if defined?(secrets.cryptoprocessing_api_namespace)
9
+ Cryptoprocessing.api_namespace = secrets.cryptoprocessing_api_namespace
10
+ end
11
+ end
12
+ end if defined?(::Rails)
13
+ end
@@ -0,0 +1,17 @@
1
+ module Cryptoprocessing
2
+ # Current major release.
3
+ # @return [Integer]
4
+ MAJOR = 0
5
+
6
+ # Current minor release.
7
+ # @return [Integer]
8
+ MINOR = 6
9
+
10
+ # Current patch level.
11
+ # @return [Integer]
12
+ PATCH = 1
13
+
14
+ # Full release version.
15
+ # @return [String]
16
+ VERSION = [MAJOR, MINOR, PATCH].join('.').freeze
17
+ end
data/script/bootstrap ADDED
@@ -0,0 +1,5 @@
1
+ #!/bin/sh
2
+
3
+ set -e
4
+
5
+ bundle install --quiet "$@"
data/script/cibuild ADDED
@@ -0,0 +1,5 @@
1
+ #!/bin/sh
2
+
3
+ set -e
4
+
5
+ script/test
data/script/console ADDED
@@ -0,0 +1,11 @@
1
+ #!/bin/sh
2
+
3
+ set -e
4
+
5
+ dir=`pwd`
6
+
7
+ echo "===> Bundling..."
8
+ script/bootstrap --quiet
9
+
10
+ echo "===> Launching..."
11
+ bundle console
data/script/package ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env bash
2
+ # Usage: script/gem
3
+ # Updates the gemspec and builds a new gem in the pkg directory.
4
+
5
+ mkdir -p pkg
6
+ gem build *.gemspec
7
+ mv *.gem pkg
data/script/release ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env bash
2
+ # Usage: script/release
3
+ # Build the package, tag a commit, push it to origin, and then release the
4
+ # package publicly.
5
+
6
+ set -e
7
+
8
+ version="$(script/package | grep Version: | awk '{print $2}')"
9
+ [ -n "$version" ] || exit 1
10
+
11
+ echo $version
12
+ git commit --allow-empty -a -m "Release $version"
13
+ git tag "v$version"
14
+ git push origin
15
+ git push origin "v$version"
16
+ gem push pkg/*-${version}.gem
data/script/test ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+
5
+ echo "===> Bundling..."
6
+ script/bootstrap --quiet
7
+
8
+ for testvar in LOGIN PASSWORD TOKEN CLIENT_ID CLIENT_SECRET
9
+ do
10
+ cryproprocessingvar="CRYPROPROCESSING_TEST_${testvar}"
11
+ if [[ -z "${!cryproprocessingvar}" ]]; then
12
+ echo "Please export ${cryproprocessingvar}";
13
+ fi
14
+ done
15
+
16
+ echo "===> Running specs..."
17
+ (unset CRYPROPROCESSING_LOGIN; unset CRYPROPROCESSING_ACCESS_TOKEN; bundle exec rake spec)
metadata ADDED
@@ -0,0 +1,236 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cryptoprocessing
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.6.1
5
+ platform: ruby
6
+ authors:
7
+ - Arthur Chafonov
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-04-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: logging
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: thor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.19'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.19'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.16'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.16'
55
+ - !ruby/object:Gem::Dependency
56
+ name: coveralls
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: faker
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '10.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '10.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: webmock
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description: Gem to access Blockchain Cryptoprocessing Platform API
140
+ email:
141
+ - actuosus@gmail.com
142
+ executables:
143
+ - cryptoprocessing
144
+ extensions: []
145
+ extra_rdoc_files: []
146
+ files:
147
+ - ".codeclimate.yml"
148
+ - ".coveralls.yml"
149
+ - ".document"
150
+ - ".editorconfig"
151
+ - ".gemtest"
152
+ - ".gitattributes"
153
+ - ".gitignore"
154
+ - ".hound.yml"
155
+ - ".rspec"
156
+ - ".rubocop.yml"
157
+ - ".rubocop_todo.yml"
158
+ - ".ruby-version"
159
+ - ".simplecov"
160
+ - ".travis.yml"
161
+ - ".yardopts"
162
+ - CHANGELOG.md
163
+ - CODE_OF_CONDUCT.md
164
+ - Gemfile
165
+ - Gemfile.lock
166
+ - LICENSE.txt
167
+ - NOTICE.txt
168
+ - README.md
169
+ - Rakefile
170
+ - VERSION
171
+ - bin/console
172
+ - bin/setup
173
+ - cryptoprocessing.gemspec
174
+ - exe/cryptoprocessing
175
+ - lib/cryptoprocessing.rb
176
+ - lib/cryptoprocessing/adapters/em_http.rb
177
+ - lib/cryptoprocessing/adapters/net_http.rb
178
+ - lib/cryptoprocessing/authentication.rb
179
+ - lib/cryptoprocessing/authentication/storages/file_token_store.rb
180
+ - lib/cryptoprocessing/authentication/storages/redis_token_store.rb
181
+ - lib/cryptoprocessing/authentication/token_store.rb
182
+ - lib/cryptoprocessing/cli.rb
183
+ - lib/cryptoprocessing/client.rb
184
+ - lib/cryptoprocessing/client/accounts.rb
185
+ - lib/cryptoprocessing/client/addresses.rb
186
+ - lib/cryptoprocessing/client/api_errors.rb
187
+ - lib/cryptoprocessing/client/api_response.rb
188
+ - lib/cryptoprocessing/client/callbacks.rb
189
+ - lib/cryptoprocessing/client/coinbase_wallet.rb
190
+ - lib/cryptoprocessing/client/net_response.rb
191
+ - lib/cryptoprocessing/client/trackers.rb
192
+ - lib/cryptoprocessing/client/transactions.rb
193
+ - lib/cryptoprocessing/configurable.rb
194
+ - lib/cryptoprocessing/connection.rb
195
+ - lib/cryptoprocessing/default.rb
196
+ - lib/cryptoprocessing/error.rb
197
+ - lib/cryptoprocessing/models/account.rb
198
+ - lib/cryptoprocessing/models/address.rb
199
+ - lib/cryptoprocessing/models/api_object.rb
200
+ - lib/cryptoprocessing/models/callback.rb
201
+ - lib/cryptoprocessing/models/tracker.rb
202
+ - lib/cryptoprocessing/models/transaction.rb
203
+ - lib/cryptoprocessing/models/user.rb
204
+ - lib/cryptoprocessing/rails.rb
205
+ - lib/cryptoprocessing/version.rb
206
+ - script/bootstrap
207
+ - script/cibuild
208
+ - script/console
209
+ - script/package
210
+ - script/release
211
+ - script/test
212
+ homepage: https://github.com/oomag/cryptoprocessing-api-client
213
+ licenses:
214
+ - MIT
215
+ metadata: {}
216
+ post_install_message:
217
+ rdoc_options: []
218
+ require_paths:
219
+ - lib
220
+ required_ruby_version: !ruby/object:Gem::Requirement
221
+ requirements:
222
+ - - ">="
223
+ - !ruby/object:Gem::Version
224
+ version: '0'
225
+ required_rubygems_version: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - ">="
228
+ - !ruby/object:Gem::Version
229
+ version: '0'
230
+ requirements: []
231
+ rubyforge_project:
232
+ rubygems_version: 2.6.11
233
+ signing_key:
234
+ specification_version: 4
235
+ summary: Client for accessing Cryptoprocessing API
236
+ test_files: []