stellar_client 0.5.2 → 0.6.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 91de0c4d8378e702695f0286e276b4087b7007c4fc879512f10de11ae671491e
4
- data.tar.gz: 8b1f83a70ae9d5639ef73915814596ff6c42f7fac5a4a1a98a435e9031939b71
3
+ metadata.gz: 7c64e163442358a81e7496c34c82538ec6b4fcbe6c6d4a4deb655628c887e6fa
4
+ data.tar.gz: 3e8f55da4581a8b9cff5c3fe4aa2b38025cdcc3209811851968710661f9d30e9
5
5
  SHA512:
6
- metadata.gz: 340f252a75dcae22c752326199052c3457366912c4a8b8ced3138df91899b87d8ea09f8e0511023a3ae6aeb01ba22510435658d87e110eecece45ca1eeda1bff
7
- data.tar.gz: 98c5f7b564d4299f556736e59b1e900f8eb5601a1650c80578070f11ea7925a287b46c5178d5b7f973e90ff7324f2959ff9bc514222d2039b737fcfbbb148a60
6
+ metadata.gz: 4badf4deac3a8395355cd7a203806cbf039a4fdaf5bee766be4d48140e594140cc449b50931264107dc67bb403a0c5917409ba3a839a563f6a1828974f68e1c0
7
+ data.tar.gz: 33b9f1f81b1590bfc01a0f704241f463713d48f6502e3bc8eb397b970a1efffb6eb079d0f2aeb4691aa8eb83ecc400062ed1f61a6155233dd8e8bf38d7567969
@@ -0,0 +1,191 @@
1
+ Rails:
2
+ Enabled: true
3
+
4
+ AllCops:
5
+ Excludes:
6
+ - "db/schema.rb"
7
+
8
+ # Bloom: Exclude RSpec and db/schema
9
+ Metrics/BlockLength:
10
+ Exclude:
11
+ - "Gemfile"
12
+ - "Rakefile"
13
+ - "db/migrate/*.rb"
14
+ - "**/*.rake"
15
+ - "spec/**/*.rb"
16
+
17
+ # Bloom: Exclude RSpec and db/schema
18
+ Metrics/ModuleLength:
19
+ Exclude:
20
+ - "Gemfile"
21
+ - "Rakefile"
22
+ - "**/*.rake"
23
+ - "spec/**/*.rb"
24
+
25
+ # Bloom prefers empty lines on classes
26
+ Layout/EmptyLinesAroundClassBody:
27
+ EnforcedStyle: empty_lines
28
+
29
+ # Bloom prefers the literal -> () call
30
+ Style/Lambda:
31
+ EnforcedStyle: literal
32
+
33
+ # Bloom prefers space in the literal -> () call
34
+ Layout/SpaceInLambdaLiteral:
35
+ EnforcedStyle: require_space
36
+
37
+ # Bloom prefers the () call
38
+ Style/LambdaCall:
39
+ Enabled: false
40
+
41
+ # Bloom: hashes/arrays look more readable if indented on the same as the hash literal
42
+ Layout/IndentHash:
43
+ EnforcedStyle: consistent
44
+ Layout/IndentArray:
45
+ EnforcedStyle: consistent
46
+
47
+ Lint/UnusedMethodArgument:
48
+ Enabled: false
49
+ Lint/UnusedBlockArgument:
50
+ Enabled: false
51
+
52
+ # Bloom: Prefer leaving trailing commas, lessens git commits
53
+ Style/TrailingCommaInArguments:
54
+ EnforcedStyleForMultiline: comma
55
+ Style/TrailingCommaInArrayLiteral:
56
+ EnforcedStyleForMultiline: comma
57
+ Style/TrailingCommaInHashLiteral:
58
+ EnforcedStyleForMultiline: comma
59
+
60
+ # Bloom: Frozen literals don't offer that much improvement for the amount of changes
61
+ # we'll need to benefit
62
+ Style/FrozenStringLiteralComment:
63
+ Enabled: false
64
+
65
+ # Bloom: Too explicit
66
+ Rails/HasManyOrHasOneDependent:
67
+ Enabled: false
68
+
69
+ # Bloom: Most methods, like factory_bot factory methods, look more readable
70
+ # when supplying attributes via a hash
71
+ Style/BracesAroundHashParameters:
72
+ Enabled: false
73
+
74
+ Metrics/LineLength:
75
+ Max: 80
76
+
77
+ Metrics/AbcSize:
78
+ Max: 20
79
+
80
+ # Too short methods lead to extraction of single-use methods, which can make
81
+ # the code easier to read (by naming things), but can also clutter the class
82
+ Metrics/MethodLength:
83
+ Max: 25
84
+
85
+ # The guiding principle of classes is SRP, SRP can't be accurately measured by LoC
86
+ Metrics/ClassLength:
87
+ Max: 1500
88
+
89
+ # Single quotes being faster is hardly measurable and only affects parse time.
90
+ # Enforcing double quotes reduces the times where you need to change them
91
+ # when introducing an interpolation. Use single quotes only if their semantics
92
+ # are needed.
93
+ Style/StringLiterals:
94
+ EnforcedStyle: double_quotes
95
+
96
+ # We do not need to support Ruby 1.9, so this is good to use.
97
+ Style/SymbolArray:
98
+ Enabled: true
99
+
100
+ # Mixing the styles looks just silly.
101
+ Style/HashSyntax:
102
+ EnforcedStyle: ruby19_no_mixed_keys
103
+
104
+ # has_key? and has_value? are far more readable than key? and value?
105
+ Style/PreferredHashMethods:
106
+ Enabled: false
107
+
108
+ # String#% is by far the least verbose and only object oriented variant.
109
+ Style/FormatString:
110
+ EnforcedStyle: percent
111
+
112
+ Style/CollectionMethods:
113
+ Enabled: true
114
+ PreferredMethods:
115
+ # inject seems more common in the community.
116
+ reduce: "inject"
117
+
118
+ # Either allow this style or don't. Marking it as safe with parenthesis
119
+ # is silly. Let's try to live without them for now.
120
+ Style/ParenthesesAroundCondition:
121
+ AllowSafeAssignment: false
122
+ Lint/AssignmentInCondition:
123
+ AllowSafeAssignment: false
124
+
125
+ # A specialized exception class will take one or more arguments and construct the message from it.
126
+ # So both variants make sense.
127
+ Style/RaiseArgs:
128
+ Enabled: false
129
+
130
+ # Indenting the chained dots beneath each other is not supported by this cop,
131
+ # see https://github.com/bbatsov/rubocop/issues/1633
132
+ Layout/MultilineOperationIndentation:
133
+ Enabled: false
134
+
135
+ # Fail is an alias of raise. Avoid aliases, it's more cognitive load for no gain.
136
+ # The argument that fail should be used to abort the program is wrong too,
137
+ # there's Kernel#abort for that.
138
+ Style/SignalException:
139
+ EnforcedStyle: only_raise
140
+
141
+ # Suppressing exceptions can be perfectly fine, and be it to avoid to
142
+ # explicitly type nil into the rescue since that's what you want to return,
143
+ # or suppressing LoadError for optional dependencies
144
+ Lint/HandleExceptions:
145
+ Enabled: false
146
+
147
+ Layout/SpaceInsideBlockBraces:
148
+ # The space here provides no real gain in readability while consuming
149
+ # horizontal space that could be used for a better parameter name.
150
+ # Also {| differentiates better from a hash than { | does.
151
+ SpaceBeforeBlockParameters: false
152
+
153
+ Layout/MultilineMethodCallIndentation:
154
+ EnforcedStyle: indented
155
+
156
+ # { ... } for multi-line blocks is okay, follow Weirichs rule instead:
157
+ # https://web.archive.org/web/20140221124509/http://onestepback.org/index.cgi/Tech/Ruby/BraceVsDoEnd.rdoc
158
+ Style/BlockDelimiters:
159
+ Enabled: false
160
+
161
+ # do / end blocks should be used for side effects,
162
+ # methods that run a block for side effects and have
163
+ # a useful return value are rare, assign the return
164
+ # value to a local variable for those cases.
165
+ Style/MethodCalledOnDoEndBlock:
166
+ Enabled: true
167
+
168
+ # Enforcing the names of variables? To single letter ones? Just no.
169
+ Style/SingleLineBlockParams:
170
+ Enabled: false
171
+
172
+ # Shadowing outer local variables with block parameters is often useful
173
+ # to not reinvent a new name for the same thing, it highlights the relation
174
+ # between the outer variable and the parameter. The cases where it's actually
175
+ # confusing are rare, and usually bad for other reasons already, for example
176
+ # because the method is too long.
177
+ Lint/ShadowingOuterLocalVariable:
178
+ Enabled: false
179
+
180
+ # Check with yard instead.
181
+ Style/Documentation:
182
+ Enabled: false
183
+
184
+ # This is just silly. Calling the argument `other` in all cases makes no sense.
185
+ Naming/BinaryOperatorParameterName:
186
+ Enabled: false
187
+
188
+ # There are valid cases, for example debugging Cucumber steps,
189
+ # also they'll fail CI anyway
190
+ Lint/Debugger:
191
+ Enabled: false
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
+ ## [0.6.0] - 2018-09-27
8
+ ### Added
9
+ - Add `StellarClient::Client.deposit`
10
+
7
11
  ## [0.5.2] - 2018-09-11
8
12
  ### Added
9
13
  - Add `WithdrawResponse#max_amount`
data/README.md CHANGED
@@ -53,7 +53,9 @@ See `spec/acceptance` for detailed examples and what is supported.
53
53
  cd spec/stellar_app
54
54
  bundle
55
55
  yarn install
56
- rails db:create db:migrate
56
+ rails db:create
57
+ rails stellar_base:install:migrations
58
+ rails db:migrate
57
59
  rails s
58
60
  ```
59
61
  - Make your changes
@@ -19,10 +19,12 @@ end
19
19
 
20
20
  require "stellar_client/client"
21
21
  require "stellar_client/coercers/indifferent_hash"
22
+ require "stellar_client/requests/deposit_request"
22
23
  require "stellar_client/requests/get_toml_request"
23
24
  require "stellar_client/requests/send_payment_request"
24
25
  require "stellar_client/requests/withdraw_request"
25
26
  require "stellar_client/responses/base_response"
27
+ require "stellar_client/responses/deposit_response"
26
28
  require "stellar_client/responses/get_toml_response"
27
29
  require "stellar_client/responses/send_payment_response"
28
30
  require "stellar_client/responses/withdraw_response"
@@ -12,6 +12,13 @@ module StellarClient
12
12
  WithdrawResponse.new(raw_response: raw_response)
13
13
  end
14
14
 
15
+ def deposit(opts = {})
16
+ transfer_host = get_toml.toml["TRANSFER_SERVER"]
17
+ request = DepositRequest.new(opts.merge(host: transfer_host))
18
+ raw_response = request.()
19
+ DepositResponse.new(raw_response: raw_response)
20
+ end
21
+
15
22
  attribute :bridge_host, String
16
23
 
17
24
  private
@@ -0,0 +1,34 @@
1
+ module StellarClient
2
+ class DepositRequest
3
+
4
+ include APIClientBase::Request.module
5
+
6
+ BODY_ATTRS = %i[
7
+ account
8
+ asset_code
9
+ memo
10
+ memo_type
11
+ email_address
12
+ type
13
+ ]
14
+ attribute :account, String
15
+ attribute :asset_code, String
16
+ attribute :memo, String
17
+ attribute :memo_type, String
18
+ attribute :email_address, String
19
+ attribute :type, String
20
+
21
+ private
22
+
23
+ def path
24
+ [Addressable::URI.parse(host).path, "/deposit"].join
25
+ end
26
+
27
+ def params
28
+ BODY_ATTRS.each_with_object({}) do |attr, hash|
29
+ hash[attr] = send(attr)
30
+ end
31
+ end
32
+
33
+ end
34
+ end
@@ -0,0 +1,45 @@
1
+ module StellarClient
2
+ class DepositResponse < BaseResponse
3
+
4
+ BODY_ATTRS = %i[
5
+ how
6
+ eta
7
+ min_amount
8
+ max_amount
9
+ fee_fixed
10
+ fee_percent
11
+ extra_info
12
+ ].freeze
13
+
14
+ attribute(:body, Coercers::IndifferentHash, {
15
+ lazy: true,
16
+ default: :default_body,
17
+ })
18
+ attribute :how, String, lazy: true, default: :default_how
19
+ attribute :eta, String, lazy: true, default: :default_eta
20
+ attribute :min_amount, BigDecimal, lazy: true, default: :default_min_amount
21
+ attribute :max_amount, BigDecimal, lazy: true, default: :default_max_amount
22
+ attribute :fee_fixed, BigDecimal, lazy: true, default: :default_fee_fixed
23
+ attribute(:fee_percent, BigDecimal, {
24
+ lazy: true,
25
+ default: :default_fee_percent,
26
+ })
27
+ attribute(:extra_info, Hash, {
28
+ lazy: true,
29
+ default: :default_extra_info,
30
+ })
31
+
32
+ private
33
+
34
+ def default_body
35
+ JSON.parse(raw_response.body)
36
+ end
37
+
38
+ BODY_ATTRS.each do |attr|
39
+ define_method("default_#{attr}".to_sym) do
40
+ body[attr]
41
+ end
42
+ end
43
+
44
+ end
45
+ end
@@ -1,3 +1,3 @@
1
1
  module StellarClient
2
- VERSION = "0.5.2".freeze
2
+ VERSION = "0.6.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stellar_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ramon Tayag
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-11 00:00:00.000000000 Z
11
+ date: 2018-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem_config
@@ -201,6 +201,7 @@ extra_rdoc_files: []
201
201
  files:
202
202
  - ".gitignore"
203
203
  - ".rspec"
204
+ - ".rubocop.yml"
204
205
  - ".ruby-version"
205
206
  - ".travis.yml"
206
207
  - CHANGELOG.md
@@ -215,10 +216,12 @@ files:
215
216
  - lib/stellar_client.rb
216
217
  - lib/stellar_client/client.rb
217
218
  - lib/stellar_client/coercers/indifferent_hash.rb
219
+ - lib/stellar_client/requests/deposit_request.rb
218
220
  - lib/stellar_client/requests/get_toml_request.rb
219
221
  - lib/stellar_client/requests/send_payment_request.rb
220
222
  - lib/stellar_client/requests/withdraw_request.rb
221
223
  - lib/stellar_client/responses/base_response.rb
224
+ - lib/stellar_client/responses/deposit_response.rb
222
225
  - lib/stellar_client/responses/get_toml_response.rb
223
226
  - lib/stellar_client/responses/send_payment_response.rb
224
227
  - lib/stellar_client/responses/withdraw_response.rb