katapaty 0.2.1 → 0.3.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
  SHA1:
3
- metadata.gz: 44c14e437f562f1c7829957e2eae125cbead5f3e
4
- data.tar.gz: 9a7b103bb8040de7e7e5726d3953dd3d326ab9f4
3
+ metadata.gz: 416163b82963bddc29b7e98feb7835556518a770
4
+ data.tar.gz: 8067a505099178e9fab2d7ac9e308ee7dfdd84e3
5
5
  SHA512:
6
- metadata.gz: eba488ec7375bda68736723515707d16f29242af014bf839c16e69379cfb658495d33063f48816b94372f70ae93cb9c5b10f737cae2a7a4a7879aabb043e2070
7
- data.tar.gz: 3b1901120dc5755910ac50f65400bf48cbe27324c0220ed3831bdc75b298cbb5c8dfa5e023a64ebfc3223ddfafa01fa37eadf62d337f2b70f12e81c165981d64
6
+ metadata.gz: e0e7a05583fe6d103131a173377514368b7e3891eaabb38db42c8cd6bc114778ef7aa95f7416d6221b4399febd0b5d801a7e4a1ddc3401086b85c99324607979
7
+ data.tar.gz: fb048bddc429e1ce4a006aa87617961d75591c78751de09758582659395b0eedd25f4c60cabda769c6a4b729936941450e82dbbd883510abaad50e6d2de54845
@@ -1,3 +1,3 @@
1
1
  module Katapaty
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
data/lib/katapaty.rb CHANGED
@@ -1,12 +1,11 @@
1
1
  require 'katapaty/version'
2
2
  require 'katapaty/configuration'
3
- require 'katapaty/resource'
4
- require 'katapaty/resources'
5
3
  require 'katapaty/errors'
6
4
 
7
5
  module Katapaty
8
6
 
9
7
  class << self
8
+
10
9
  attr_writer :configuration
11
10
 
12
11
  def configuration
@@ -21,9 +20,10 @@ module Katapaty
21
20
  yield(configuration)
22
21
  end
23
22
 
24
- def request(method, params)
23
+ def method_missing(name, *args)
24
+ args = args.nil? ? nil : args.first
25
25
  client = RestClient::Resource.new @configuration.api_url
26
- request = { method: method, params: params, jsonrpc: '2.0', id: '0' }.to_json
26
+ request = { method: name, params: args, jsonrpc: '2.0', id: '0' }.to_json
27
27
  response = JSON.parse client.post(request,
28
28
  user: @configuration.username,
29
29
  password: @configuration.password,
@@ -33,18 +33,5 @@ module Katapaty
33
33
  raise ResponseError.new response['error'] if response.has_key? 'error'
34
34
  response['result']
35
35
  end
36
-
37
- Katapaty::Resources.constants.each do |c|
38
- begin
39
- define_method(:"get_#{c.to_s.pluralize.downcase}") do |params|
40
- self.request((__method__).to_s, params)
41
- end
42
- define_method(:"create_#{c.to_s.downcase}") do |params|
43
- self.request((__method__).to_s, params)
44
- end
45
- rescue NameError
46
- next
47
- end
48
- end
49
36
  end
50
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: katapaty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - longhoang.wkm
@@ -72,8 +72,6 @@ files:
72
72
  - lib/katapaty.rb
73
73
  - lib/katapaty/configuration.rb
74
74
  - lib/katapaty/errors.rb
75
- - lib/katapaty/resource.rb
76
- - lib/katapaty/resources.rb
77
75
  - lib/katapaty/version.rb
78
76
  homepage: https://github.com/longhoangwkm/katapaty
79
77
  licenses:
@@ -1,9 +0,0 @@
1
- module Katapaty
2
- class Resource
3
- class << self
4
- def api_name
5
- to_s.split('::').last.gsub(/[^\A]([A-Z])/, '_\\1').downcase
6
- end
7
- end
8
- end
9
- end
@@ -1,533 +0,0 @@
1
- module Katapaty::Resources
2
- class Balance < Katapaty::Resource
3
- attr_accessor :address,
4
- :asset,
5
- :quantity
6
- end
7
-
8
- class Send < Katapaty::Resource
9
- attr_accessor :tx_index,
10
- :tx_hash,
11
- :block_index,
12
- :source,
13
- :destination,
14
- :asset,
15
- :quantity,
16
- :validity
17
- end
18
-
19
- class Broadcast < Katapaty::Resource
20
- # Value: Open Broadcast
21
- OPEN_BROADCAST = -1.0
22
-
23
- # (integer): The transaction index
24
- attr_accessor :tx_index
25
-
26
- # (string): The transaction hash
27
- attr_accessor :tx_hash
28
-
29
- # (integer): The block index (block number in the block chain)
30
- attr_accessor :block_index
31
-
32
- # (string): The address that made the broadcast
33
- attr_accessor :source
34
-
35
- # (string): The time the broadcast was made, in Unix time.
36
- attr_accessor :timestamp
37
-
38
- # (float): The numerical value of the broadcast
39
- attr_accessor :value
40
-
41
- # (float): How much of every bet on this feed should go to its operator;
42
- # a fraction of 1, (i.e. .05 is five percent)
43
- attr_accessor :fee_multiplier
44
-
45
- # (string): The textual component of the broadcast
46
- attr_accessor :text
47
-
48
- # (string): Set to "valid" if a valid broadcast. Any other setting signifies
49
- # an invalid/improper broadcast
50
- attr_accessor :validity
51
-
52
- # (float): How much of every bet on this feed should go to its
53
- # operator; a fraction of 1, (i.e. .05 is five percent). Used on create.
54
- attr_accessor :fee_fraction
55
- end
56
-
57
- # An object that describes an instance of a specific burn.
58
- class Burn < Katapaty::Resource
59
- # (integer): The transaction index
60
- attr_accessor :tx_index
61
-
62
- # (string): The transaction hash
63
- attr_accessor :tx_hash
64
-
65
- # (integer): The block index (block number in the block chain)
66
- attr_accessor :block_index
67
-
68
- # (string): The address the burn was performed from
69
- attr_accessor :source
70
-
71
- # (integer): The quantity of BTC burned
72
- attr_accessor :burned
73
-
74
- # (integer): The quantity of XPC actually earned from the burn (takes into
75
- # account any bonus quantitys, 1 BTC limitation, etc)
76
- attr_accessor :earned
77
-
78
- # (string): Set to "valid" if a valid burn. Any other setting signifies an
79
- # invalid/improper burn
80
- attr_accessor :validity
81
-
82
- # (string): Set to "valid" if a valid burn. Any other setting signifies an
83
- # invalid/improper burn
84
- attr_accessor :status
85
-
86
- # (integer): The amount of BTC to burn (only used in the Create Burn)
87
- attr_accessor :quantity
88
- end
89
-
90
- # An object that describes a specific asset callback (i.e. the exercising of
91
- # a call option on an asset owned by the source address).
92
- class Callback < Katapaty::Resource
93
- # (integer): The transaction index
94
- attr_accessor :tx_index
95
-
96
- # (string): The transaction hash
97
- attr_accessor :tx_hash
98
-
99
- # block_index (integer): The block index (block number in the block chain)
100
- attr_accessor :block_index
101
-
102
- # (string): The source address of the call back (should be the current owner
103
- # of the asset)
104
- attr_accessor :source
105
-
106
- # (integer): A floating point number greater than zero but less than or
107
- # equal to 1, where 0% is for a callback of 0%
108
- attr_accessor :fraction
109
-
110
- # of the balance of each of the asset's holders, and 1 would be for a
111
- # callback of 100%). For example, 0.56 would be 56%. Each holder of the
112
- # called asset will be paid the call price for the asset, times the number
113
- # of units of that asset that were called back from them.
114
- attr_accessor :of
115
-
116
- # (string): The asset being called back
117
- attr_accessor :asset
118
-
119
- # (string): Set to "valid" if a valid send. Any other setting signifies an
120
- # invalid/improper send
121
- attr_accessor :validity
122
- end
123
-
124
- # An object that describes a cancellation of a (previously) open order or bet.
125
- class Cancel < Katapaty::Resource
126
- # (integer): The transaction index
127
- attr_accessor :tx_index
128
-
129
- # (string): The transaction hash
130
- attr_accessor :tx_hash
131
-
132
- # (integer): The block index (block number in the block chain)
133
- attr_accessor :block_index
134
-
135
- # (string): The address with the open order or bet that was cancelled
136
- attr_accessor :source
137
-
138
- # (string): The transaction hash of the order or bet cancelled
139
- attr_accessor :offer_hash
140
-
141
- # (string): Set to "valid" if a valid burn. Any other setting signifies an
142
- # invalid/improper burn
143
- attr_accessor :validity
144
- end
145
-
146
- # An object that describes a account credit.
147
- class Credit < Katapaty::Resource
148
- # (integer): The transaction index
149
- attr_accessor :tx_index
150
-
151
- # (string): The transaction hash
152
- attr_accessor :tx_hash
153
-
154
- # (integer): The block index (block number in the block chain)
155
- attr_accessor :block_index
156
-
157
- # (string): The address debited or credited
158
- attr_accessor :address
159
-
160
- # (string): The asset debited or credited
161
- attr_accessor :asset
162
-
163
- # (integer): The quantity of the specified asset debited or credited
164
- attr_accessor :quantity
165
-
166
- attr_accessor :action
167
-
168
- attr_accessor :event
169
- end
170
-
171
- # An object that describes a account debit or credit.
172
- class Debit < Katapaty::Resource
173
- # (integer): The transaction index
174
- attr_accessor :tx_index
175
-
176
- # (string): The transaction hash
177
- attr_accessor :tx_hash
178
-
179
- # (integer): The block index (block number in the block chain)
180
- attr_accessor :block_index
181
-
182
- # (string): The address debited or credited
183
- attr_accessor :address
184
-
185
- # (string): The asset debited or credited
186
- attr_accessor :asset
187
-
188
- # (integer): The quantity of the specified asset debited or credited
189
- attr_accessor :quantity
190
-
191
- attr_accessor :action
192
-
193
- attr_accessor :event
194
- end
195
-
196
- # An object that describes an issuance of dividends on a specific user
197
- # defined asset.
198
- class Dividend < Katapaty::Resource
199
- # (integer): The transaction index
200
- attr_accessor :tx_index
201
-
202
- # (string): The transaction hash
203
- attr_accessor :tx_hash
204
-
205
- # (integer): The block index (block number in the block chain)
206
- attr_accessor :block_index
207
-
208
- # (string): The address that issued the dividend
209
- attr_accessor :source
210
-
211
- # (string): The asset that the dividends are being rewarded on
212
- attr_accessor :asset
213
-
214
- # (integer): The quantity of XCP rewarded per whole unit of the asset
215
- attr_accessor :quantity_per_unit
216
-
217
- # (string): Set to "valid" if a valid burn. Any other setting signifies an
218
- # invalid/improper burn
219
- attr_accessor :validity
220
-
221
- # (string, required): The asset that the dividends are paid in.
222
- attr_accessor :dividend_asset
223
- end
224
-
225
- # An object that describes a specific occurance of a user defined asset being
226
- # issued, or re-issued
227
- class Issuance < Katapaty::Resource
228
- # (integer): The transaction index
229
- attr_accessor :tx_index
230
-
231
- # (string): The transaction hash
232
- attr_accessor :tx_hash
233
-
234
- # (integer): The block index (block number in the block chain)
235
- attr_accessor :block_index
236
-
237
- # (string): The asset being issued, or re-issued
238
- attr_accessor :asset
239
-
240
- # (integer): The quantity of the specified asset being issued
241
- attr_accessor :quantity
242
-
243
- # (boolean): Whether or not the asset is divisible (must agree with previous
244
- # issuances of the asset, if there are any)
245
- attr_accessor :divisible
246
-
247
- # issuer (string):
248
- attr_accessor :issuer
249
-
250
- # (boolean): Whether or not this objects marks the transfer of ownership
251
- # rights for the specified quantity of this asset
252
- attr_accessor :transfer
253
-
254
- # (string): Set to "valid" if a valid issuance. Any other setting signifies
255
- # an invalid/improper issuance
256
- attr_accessor :validity
257
-
258
- # (string): This is used when creating an issuance, and indicates the source
259
- # address of the asset
260
- attr_accessor :source
261
-
262
- # (string): This is used when creating an issuance, and indicates
263
- # the destination address of the asset
264
- attr_accessor :description
265
-
266
- # (string): This is used when creating an issuance transfer, and indicates
267
- # the destination address of the asset
268
- attr_accessor :transfer_destination
269
- end
270
-
271
- # An object that describes a specific order.
272
- class Order < Katapaty::Resource
273
- # (integer): The transaction index
274
- attr_accessor :tx_index
275
-
276
- # (string): The transaction hash
277
- attr_accessor :tx_hash
278
-
279
- # (integer): The block index (block number in the block chain)
280
- attr_accessor :block_index
281
-
282
- # (string): The address that made the order
283
- attr_accessor :source
284
-
285
- # (string): The asset being offered
286
- attr_accessor :give_asset
287
-
288
- # (integer): The quantity of the specified asset being offered
289
- attr_accessor :give_quantity
290
-
291
- # (integer): The quantity of the specified give asset remaining for the order
292
- attr_accessor :give_remaining
293
-
294
- # (string): The asset desired in exchange
295
- attr_accessor :get_asset
296
-
297
- # (integer): The quantity of the specified asset desired in exchange
298
- attr_accessor :get_quantity
299
-
300
- # (integer): The quantity of the specified get asset remaining for the order
301
- attr_accessor :get_remaining
302
-
303
- # (float): The given exchange rate (as an exchange ratio desired from the
304
- # asset offered to the asset desired)
305
- attr_accessor :price
306
-
307
- # (integer): The number of blocks over which the order should be valid
308
- attr_accessor :expiration
309
-
310
- # (integer): The miners' fee provided; in BTC; required only if selling BTC
311
- # (should not be lower than is required for acceptance in a block)
312
- attr_accessor :fee_provided
313
-
314
- # (integer): The miners' fee required to be paid by orders for them to match
315
- # this one; in BTC; required only if buying BTC (may be zero, though)
316
- attr_accessor :fee_required
317
- end
318
-
319
- # An object that describes a specific occurance of two orders being matched
320
- # (either partially, or fully)
321
- class OrderMatch < Katapaty::Resource
322
- # (integer): The Bitcoin transaction index of the first (earlier) order
323
- attr_accessor :tx0_index
324
-
325
- # (string): The Bitcoin transaction hash of the first order
326
- attr_accessor :tx0_hash
327
-
328
- # (integer): The Bitcoin block index of the first order
329
- attr_accessor :tx0_block_index
330
-
331
- # (integer): The number of blocks over which the first order was valid
332
- attr_accessor :tx0_expiration
333
-
334
- # (string): The address that issued the first (earlier) order
335
- attr_accessor :tx0_address
336
-
337
- # (integer): The transaction index of the second (matching) order
338
- attr_accessor :tx1_index
339
-
340
- # (string): The transaction hash of the second order
341
- attr_accessor :tx1_hash
342
-
343
- # (integer): The block index of the second order
344
- attr_accessor :tx1_block_index
345
-
346
- # (string): The address that issued the second order
347
- attr_accessor :tx1_address
348
-
349
- # (integer): The number of blocks over which the second order was valid
350
- attr_accessor :tx1_expiration
351
-
352
- # (string): The asset exchanged FROM the first order to the second order
353
- attr_accessor :forward_asset
354
-
355
- # (integer): The quantity of the specified forward asset
356
- attr_accessor :forward_quantity
357
-
358
- # (string): The asset exchanged FROM the second order to the first order
359
- attr_accessor :backward_asset
360
-
361
- # (integer): The quantity of the specified backward asset
362
- attr_accessor :backward_quantity
363
-
364
- # (string): Set to "valid" if a valid order match. Any other setting
365
- # signifies an invalid/improper order match
366
- attr_accessor :validity
367
- end
368
-
369
- # An object that describes a specific event in the counterpartyd message feed
370
- # (which can be used by 3rd party applications to track state changes to the
371
- # counterpartyd database on a block-by-block basis).
372
- class Message < Katapaty::Resource
373
- # (integer): The message index (i.e. transaction index)
374
- attr_accessor :message_index
375
-
376
- # (integer): The block index (block number in the block chain) this event
377
- # occurred on
378
- attr_accessor :block_index
379
-
380
- # (string): A string denoting the entity that the message relates to, e.g.
381
- # "credits", "burns", "debits". The category matches the relevant table name
382
- # in counterpartyd (see blocks.py for more info).
383
- attr_accessor :category
384
-
385
- # (string): The operation done to the table noted in category. This is
386
- # either "insert", or "update".
387
- attr_accessor :command
388
-
389
- # (string): A JSON-encoded object containing the message data. The
390
- # properties in this object match the columns in the table referred to by category.
391
- attr_accessor :bindings
392
- end
393
-
394
- # An object that describes a specific asset callback (i.e. the exercising of
395
- # a call option on an asset owned by the source address).
396
- class Callback < Katapaty::Resource
397
- # (integer): The transaction index
398
- attr_accessor :tx_index
399
-
400
- # (string): The transaction hash
401
- attr_accessor :tx_hash
402
-
403
- # (integer): The block index (block number in the block chain)
404
- attr_accessor :block_index
405
-
406
- # (string): The source address of the call back (should be the current owner
407
- # of the asset)
408
- attr_accessor :source
409
-
410
- # (integer): A floating point number greater than zero but less than
411
- # or equal to 1, where 0% is for a callback of 0% of the balance of each of
412
- # the asset's holders, and 1 would be for a callback of 100%). For example,
413
- # 0.56 would be 56%. Each holder of the called asset will be paid the call
414
- # price for the asset, times the number of units of that asset that were
415
- # called back from them.
416
- attr_accessor :fraction
417
-
418
- # asset (string): The asset being called back
419
- attr_accessor :asset
420
-
421
- # (string): Set to "valid" if a valid send. Any other setting signifies an
422
- # invalid/improper send
423
- attr_accessor :validity
424
- end
425
-
426
- # An object that describes the expiration of a bet created by the source
427
- # address.
428
- class BetExpiration < Katapaty::Resource
429
- # (integer): The transaction index of the bet expiring
430
- attr_accessor :bet_index
431
-
432
- # bet_hash (string): The transaction hash of the bet expiriing
433
- attr_accessor :bet_hash
434
-
435
- # (integer): The block index (block number in the block chain) when this
436
- # expiration occurred
437
- attr_accessor :block_index
438
-
439
- # (string): The source address that created the bet
440
- attr_accessor :source
441
- end
442
-
443
- # An object that describes the expiration of an order created by the source
444
- # address.
445
- class OrderExpiration < Katapaty::Resource
446
- # (integer): The transaction index of the order expiring
447
- attr_accessor :order_index
448
-
449
- # (string): The transaction hash of the order expiriing
450
- attr_accessor :order_hash
451
-
452
- # (integer): The block index (block number in the block chain) when this
453
- # expiration occurred
454
- attr_accessor :block_index
455
-
456
- # (string): The source address that created the order
457
- attr_accessor :source
458
- end
459
-
460
- # An object that describes the expiration of a bet match.
461
- class BetMatchExpiration < Katapaty::Resource
462
- # (integer): The transaction index of the bet match ID (e.g. the
463
- # concatenation of the tx0 and tx1 hashes)
464
- attr_accessor :bet_match_id
465
-
466
- # (string): The tx0 (first) address for the bet match
467
- attr_accessor :tx0_address
468
-
469
- # (string): The tx1 (second) address for the bet match
470
- attr_accessor :tx1_address
471
-
472
- # (integer): The block index (block number in the block chain) when this
473
- # expiration occurred
474
- attr_accessor :block_index
475
- end
476
-
477
- # An object that describes the expiration of an order match.
478
- class OrderMatchExpiration < Katapaty::Resource
479
- # (integer): The transaction index of the order match ID (e.g. the
480
- # concatenation of the tx0 and tx1 hashes)
481
- attr_accessor :order_match_id
482
-
483
- # (string): The tx0 (first) address for the order match
484
- attr_accessor :tx0_address
485
-
486
- # (string): The tx1 (second) address for the order match
487
- attr_accessor :tx1_address
488
-
489
- # (integer): The block index (block number in the block chain) when this
490
- # expiration occurred
491
- attr_accessor :block_index
492
- end
493
-
494
- # An object that publishes a compiled serpent contract onto the Counterparty
495
- # network
496
- class Publish < Katapaty::Resource
497
- # (string) the source address
498
- attr_accessor :source
499
-
500
- # (integer) the price of gas
501
- attr_accessor :gasprice
502
-
503
- # (integer) the maximum quantity of {} to be used to pay for the execution (satoshis)
504
- attr_accessor :startgas
505
-
506
- # (integer) quantity of {} to be transfered to the contract (satoshis)
507
- attr_accessor :endowment
508
-
509
- # (string) the hex‐encoded contract (returned by 'serpent compile')
510
- attr_accessor :code_hex
511
- end
512
-
513
- # An object that executes contract code in the blockchain
514
- class Execute < Katapaty::Resource
515
- # (string) the source address
516
- attr_accessor :source
517
-
518
- # (integer) the price of gas
519
- attr_accessor :gasprice
520
-
521
- # (integer) the maximum quantity of {} to be used to pay for the execution (satoshis
522
- attr_accessor :startgas
523
-
524
- # (integer) the contract ID of the contract to be executed
525
- attr_accessor :contract_id
526
-
527
- # (integer) quantity to be transfered to the contract (satoshis)
528
- attr_accessor :value
529
-
530
- # (string) data to be provided to the contract (returned by serpent encode_datalist)
531
- attr_accessor :payload_hex
532
- end
533
- end