vingd 0.1.2 → 0.1.3

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 (2) hide show
  1. data/lib/vingd.rb +27 -16
  2. metadata +2 -2
@@ -8,7 +8,7 @@ require 'vingd/response'
8
8
  require 'vingd/exceptions'
9
9
 
10
10
  class Vingd
11
- VERSION = "0.1.2"
11
+ VERSION = "0.1.3"
12
12
 
13
13
  # production urls
14
14
  URL_ENDPOINT = "https://api.vingd.com/broker/v1"
@@ -148,15 +148,14 @@ class Vingd
148
148
  return self.request('post', 'rewards', data)
149
149
  end
150
150
 
151
- # Does delegated (pre-authorized) purchase of `oid` in the name of `huid`, at
152
- # price `price` (vingd transferred from `huid` to consumer's acc).
153
- # Throws exception on failure.
154
- def authorized_purchase_object(oid, price, huid)
155
- # autocommit = true, by default
156
- end
157
-
158
- def authorized_purchase_order(orderid, huid)
159
- end
151
+
152
+
153
+
154
+
155
+ # Returns account balance (in vingd cents) for user defined with `huid`.
156
+ def authorized_get_account_balance(huid)
157
+ return self.request('get', 'fort/accounts/' + huid)['balance'].to_i
158
+ end
160
159
 
161
160
  # authorized_create_user(
162
161
  # {"facebook" => "12312312", "mail" => "user@example.com"},
@@ -165,12 +164,24 @@ class Vingd
165
164
  # )
166
165
  # Returns Vingd user's `huid` (hashed user id).
167
166
  # Throws exception on failure.
168
- def authorized_create_user(identities, primary, delegate_permissions = nil)
167
+ def authorized_create_user(identities, primary, permissions = nil)
168
+ data = JSON.dump({
169
+ 'identities' => identities,
170
+ 'primary' => primary,
171
+ 'delegate_permissions' => permissions,
172
+ })
173
+ return self.request('post', 'id/users/', data)
169
174
  end
170
175
 
171
- # Returns account balance (in vingd cents) for user defined with `huid`.
172
- def authorized_get_balance(huid)
173
- end
176
+ # Does delegated (pre-authorized) purchase of `oid` in the name of `huid`, at
177
+ # price `price` (vingd transferred from `huid` to consumer's acc).
178
+ # Throws exception on failure.
179
+ def authorized_purchase_object(oid, price, huid)
180
+ data = JSON.dump({
181
+ 'price' => price,
182
+ 'huid' => huid,
183
+ 'autocommit' => true,
184
+ })
185
+ return self.request('post', "objects/#{oid}/purchases", data)
186
+ end
174
187
  end
175
-
176
-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vingd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-11-20 00:00:00.000000000 Z
12
+ date: 2013-11-22 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Vingd enables users to pay with money or with time. See https://www.vingd.com
15
15
  for more.