vingd 0.1.4 → 0.1.5
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.
- data/lib/vingd.rb +12 -9
- metadata +39 -21
data/lib/vingd.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'net/
|
1
|
+
require 'net/https'
|
2
2
|
require "base64"
|
3
3
|
require "uri"
|
4
4
|
require 'json'
|
@@ -8,7 +8,7 @@ require 'vingd/response'
|
|
8
8
|
require 'vingd/exceptions'
|
9
9
|
|
10
10
|
class Vingd
|
11
|
-
VERSION = "0.1.
|
11
|
+
VERSION = "0.1.5"
|
12
12
|
|
13
13
|
# production urls
|
14
14
|
URL_ENDPOINT = "https://api.vingd.com/broker/v1"
|
@@ -129,7 +129,7 @@ class Vingd
|
|
129
129
|
def create_order(oid, price, context=nil, expires=nil)
|
130
130
|
expires.is_a?(DateTime) or expires = DateTime.now.new_offset(0) + 30
|
131
131
|
data = JSON.dump({
|
132
|
-
'price' => price,
|
132
|
+
'price' => (price * 100).round,
|
133
133
|
'order_expires' => expires.iso8601,
|
134
134
|
'context'=> context,
|
135
135
|
})
|
@@ -138,12 +138,12 @@ class Vingd
|
|
138
138
|
return orderid
|
139
139
|
end
|
140
140
|
|
141
|
-
# User `huid` gets `amount`
|
141
|
+
# User `huid` gets `amount` vingds (transferred from consumer's acc), or
|
142
142
|
# on failure, an exception gets thrown.
|
143
143
|
def reward_user(huid_to, amount, description = nil)
|
144
144
|
data = JSON.dump({
|
145
145
|
'huid_to' => huid_to,
|
146
|
-
'amount' => amount,
|
146
|
+
'amount' => (amount * 100).round,
|
147
147
|
'description' => description,
|
148
148
|
})
|
149
149
|
return self.request('post', 'rewards', data)
|
@@ -153,9 +153,10 @@ class Vingd
|
|
153
153
|
|
154
154
|
|
155
155
|
|
156
|
-
# Returns account balance (in
|
156
|
+
# Returns account balance (in vingds) for user defined with `huid`.
|
157
157
|
def authorized_get_account_balance(huid)
|
158
|
-
|
158
|
+
balance_cents = self.request('get', 'fort/accounts/' + huid)['balance'].to_i
|
159
|
+
return balance_cents / 100.0
|
159
160
|
end
|
160
161
|
|
161
162
|
# authorized_create_user(
|
@@ -179,10 +180,12 @@ class Vingd
|
|
179
180
|
# Throws exception on failure.
|
180
181
|
def authorized_purchase_object(oid, price, huid)
|
181
182
|
data = JSON.dump({
|
182
|
-
'price' => price,
|
183
|
+
'price' => (price * 100).round,
|
183
184
|
'huid' => huid,
|
184
185
|
'autocommit' => true,
|
185
186
|
})
|
186
|
-
|
187
|
+
ret = self.request('post', "objects/#{oid}/purchases", data)
|
188
|
+
ret['cost'] /= 100.0
|
189
|
+
return ret
|
187
190
|
end
|
188
191
|
end
|
metadata
CHANGED
@@ -1,50 +1,68 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: vingd
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 5
|
10
|
+
version: 0.1.5
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Vingd, Inc.
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
17
|
+
|
18
|
+
date: 2013-12-04 00:00:00 Z
|
13
19
|
dependencies: []
|
14
|
-
|
15
|
-
|
20
|
+
|
21
|
+
description: Vingd enables users to pay with money or with time. See https://www.vingd.com for more.
|
16
22
|
email: developers@vingd.com
|
17
23
|
executables: []
|
24
|
+
|
18
25
|
extensions: []
|
26
|
+
|
19
27
|
extra_rdoc_files: []
|
20
|
-
|
28
|
+
|
29
|
+
files:
|
21
30
|
- LICENSE
|
22
31
|
- lib/vingd.rb
|
23
32
|
- lib/vingd/response.rb
|
24
33
|
- lib/vingd/exceptions.rb
|
25
34
|
homepage: https://git.vingd.com/vingd/vingd-api-ruby
|
26
|
-
licenses:
|
35
|
+
licenses:
|
27
36
|
- MIT
|
28
37
|
post_install_message:
|
29
38
|
rdoc_options: []
|
30
|
-
|
39
|
+
|
40
|
+
require_paths:
|
31
41
|
- lib
|
32
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
33
43
|
none: false
|
34
|
-
requirements:
|
35
|
-
- -
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
|
38
|
-
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
hash: 3
|
48
|
+
segments:
|
49
|
+
- 0
|
50
|
+
version: "0"
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
39
52
|
none: false
|
40
|
-
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 3
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
version: "0"
|
44
60
|
requirements: []
|
61
|
+
|
45
62
|
rubyforge_project:
|
46
|
-
rubygems_version: 1.8.
|
63
|
+
rubygems_version: 1.8.15
|
47
64
|
signing_key:
|
48
65
|
specification_version: 3
|
49
66
|
summary: Vingd API interface client.
|
50
67
|
test_files: []
|
68
|
+
|