social_wallet 1.1.0 → 1.2.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 +4 -4
- data/README.md +8 -2
- data/lib/social_wallet/client.rb +4 -2
- data/lib/social_wallet/version.rb +1 -1
- data/test_env.yml.example +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4a455067fda9d8fee196062f7702871c045a672
|
4
|
+
data.tar.gz: 331643bfd1ce3a654a66bd79ae4b0f1c5433f017
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e0546c69bbf6f17b6df361b6e3fd628981466b9ff9e675f9840b22a51ecdcdcbf53a29016c2b7add54acfa69bc6d9ef32b28e0a00fecfe541e9ee9743d288a8
|
7
|
+
data.tar.gz: ae5b13893e916dd280c32a5d690367ed95d674ac5f212629c9cee14c7346db6609f5b861039dda9e1fd89ffb933e3d012fa827061f5ff5b3bf48f9925602fd91
|
data/README.md
CHANGED
@@ -22,21 +22,27 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
### ⚠️ Version compatibility ⚠️
|
24
24
|
|
25
|
+
If you use [Social Wallet API](https://github.com/Commonfare-net/social-wallet-api) version 1.0 you must use [v1.1.0 of this gem](https://github.com/Commonfare-net/social_wallet_ruby/tree/d65c45e0aaca07cdf3a3affc483bb38d3dbef1c0).
|
26
|
+
|
25
27
|
If you use [Social Wallet API](https://github.com/Commonfare-net/social-wallet-api) version ≤ 0.10.x you must use [v1.0.3 of this gem](https://github.com/Commonfare-net/social_wallet_ruby/tree/5fe6ee36f3055de165540f49eb03e54ea9fc268d).
|
26
28
|
|
29
|
+
### Get the API KEY
|
30
|
+
|
31
|
+
See [this guide](https://github.com/Commonfare-net/social-wallet-api/blob/master/APIKEY.md) for obtaining your API key.
|
32
|
+
|
27
33
|
### Create the client
|
28
34
|
|
29
35
|
The default client uses the *database* `mongo` as backend.
|
30
36
|
|
31
37
|
```ruby
|
32
|
-
client = SocialWallet::Client.new(api_endpoint: 'http://example.com/wallet/v1')
|
38
|
+
client = SocialWallet::Client.new(api_endpoint: 'http://example.com/wallet/v1', api_key: 'YOUR_API_KEY')
|
33
39
|
```
|
34
40
|
|
35
41
|
This constructor defaults to a client that uses `connection: 'mongo'` and `type: 'db-only'`.
|
36
42
|
If you want to use the API on a different backend just specify it like this:
|
37
43
|
|
38
44
|
```ruby
|
39
|
-
client = SocialWallet::Client.new(api_endpoint: 'http://example.com/wallet/v1', connection: 'faircoin', type: 'blockchain-and-db')
|
45
|
+
client = SocialWallet::Client.new(api_endpoint: 'http://example.com/wallet/v1', api_key: 'YOUR_API_KEY', connection: 'faircoin', type: 'blockchain-and-db')
|
40
46
|
```
|
41
47
|
|
42
48
|
### List of tags
|
data/lib/social_wallet/client.rb
CHANGED
@@ -1,16 +1,18 @@
|
|
1
1
|
module SocialWallet
|
2
2
|
class Client
|
3
|
-
attr_accessor :api_endpoint, :blockchain, :request_data, :connection, :type
|
3
|
+
attr_accessor :api_endpoint, :api_key, :blockchain, :request_data, :connection, :type
|
4
4
|
|
5
5
|
SW_ERROR_STATUSES = [404, 503].freeze
|
6
6
|
|
7
7
|
def initialize(
|
8
8
|
api_endpoint: nil,
|
9
|
+
api_key: '',
|
9
10
|
blockchain: 'mongo',
|
10
11
|
connection: 'mongo',
|
11
12
|
type: 'db-only'
|
12
13
|
)
|
13
14
|
@api_endpoint = api_endpoint
|
15
|
+
@api_key = api_key
|
14
16
|
@blockchain = blockchain # NOTE: here for backward compatibility
|
15
17
|
@connection = connection
|
16
18
|
@type = type
|
@@ -232,7 +234,7 @@ module SocialWallet
|
|
232
234
|
def headers
|
233
235
|
{
|
234
236
|
'Content-Type' => 'application/json',
|
235
|
-
|
237
|
+
'x-api-key' => api_key
|
236
238
|
}
|
237
239
|
end
|
238
240
|
end
|
data/test_env.yml.example
CHANGED