widgit_accounts_sdk 0.0.3 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b364cf8e9313f1f8bdaa1dc6151d88596330c051dfe4f0469d55060d95115fc9
4
- data.tar.gz: a623561a5792d926aa9ed4b8c562e30f766cad36a548bec2d8b7c19bde59186c
3
+ metadata.gz: 9a8700049f4e5290a4821b727174056d1caa889f3dafb1431734f879d36aea10
4
+ data.tar.gz: ae0399123fe9afe15bee081347e136e8085bf12e11466954fa168f5db8472520
5
5
  SHA512:
6
- metadata.gz: 6b808013be4175d5000064892d07106c0869158b1acdc271706a4f15b32e883cd09f8e39ad406e2bd1d328329b6021a8ac1d2e4de6c24a171b94c8dd695f381a
7
- data.tar.gz: 9eeae767b91a3ffeeb37afeb3a3962d097e2200cd73829ffee14983e9b8f6ff8bf9c158b05b05aaa9c56f4cd68a064fc9b484c6062adb0e20d273b8197ef642d
6
+ metadata.gz: ec09a895498c0410489c564dafdc809a36834691e69b809355943f926fc1e546d85491e8d29044dcd8f310491080155c461d66767b2263a059f3b316196f5271
7
+ data.tar.gz: 91403cee348a7c8dacc73e63bac01004903e895f248c32c6e073ec8315c8b207cd224ecd94f02ad08e84702f532caeee042ad86aff6006d9461e36ca3824adf2
@@ -6,59 +6,60 @@ module WidgitAccountsSdk
6
6
  extend self
7
7
 
8
8
  def find_with_uid(uid)
9
- response = request("/api/v1/accounts?uid=#{uid}")
10
- return failed(response['error']) if response['status'] == 'failure'
9
+ response = request("/api/v1/accounts?#{uid.to_query(:uid)}")
10
+ return failed(response['error']) if response['status'] == 'failed'
11
11
  return success.merge('account' => response.dig('data', 0))
12
12
  end
13
13
 
14
14
  def find_with_email(email)
15
- response = request("/api/v1/accounts?email=#{email}")
16
- return failed(response['error']) if response['status'] == 'failure'
15
+ response = request("/api/v1/accounts?#{email.to_query(:email)}")
16
+ return failed(response['error']) if response['status'] == 'failed'
17
17
  return success.merge('account' => response.dig('data', 0))
18
18
  end
19
19
 
20
20
  def find_with_username(username)
21
- response = request("/api/v1/accounts?username=#{username}")
22
- return failed(response['error']) if response['status'] == 'failure'
21
+ response = request("/api/v1/accounts?#{username.to_query(:username)}")
22
+ return failed(response['error']) if response['status'] == 'failed'
23
23
  return success.merge('account' => response.dig('data', 0))
24
24
  end
25
25
 
26
26
  def exists?(email)
27
- response = request("/api/v1/accounts/check?email=#{email}")
28
- return failed(response['error']) if response['status'] == 'failure'
27
+ response = request("/api/v1/accounts/check?#{email.to_query(:email)}")
28
+ return failed(response['error']) if response['status'] == 'failed'
29
29
  return success.merge('exists' => response['exists'])
30
30
  end
31
31
 
32
32
  def invite(email, first_name = nil, last_name = nil)
33
- request_url = "/api/v1/accounts/invite?email=#{email}"
34
- request_url += "&first_name=#{first_name}" if first_name
35
- request_url += "&last_name=#{last_name}" if last_name
33
+ request_url = "/api/v1/accounts/invite?#{email.to_query(:email)}"
34
+ request_url += "&#{first_name.to_query(:first_name)}" if first_name
35
+ request_url += "&#{last_name.to_query(:last_name)}" if last_name
36
36
  response = request(request_url, :post)
37
- return failed(response['error']) if response['status'] == 'failure'
37
+ return failed(response['error']) if response['status'] == 'failed'
38
38
  return response
39
39
  end
40
40
 
41
41
  def get_new_invite_token(email)
42
- response = request("/api/v1/accounts/invite?email=#{email}", :post)
42
+ response = request("/api/v1/accounts/invite?#{email.to_query(:email)}", :post)
43
43
  return response['data']['invitation_token'] if response['status'] == 'success'
44
44
  return nil
45
45
  end
46
46
 
47
47
  def create_account(params)
48
48
  response = request("/api/v1/accounts", :post, params)
49
- return failed(response['error']) if response['status'] == 'failure'
49
+ return failed(response['error']) if response['status'] == 'failed'
50
50
  return response
51
51
  end
52
52
 
53
53
  def update_account(uid, params)
54
54
  response = request("/api/v1/accounts/#{uid}", :patch, params)
55
- return failed(response['error']) if response['status'] == 'failure'
55
+ return failed(response['error']) if response['status'] == 'failed'
56
56
  return response
57
57
  end
58
58
 
59
59
  def watch(uid, watcher_url = nil)
60
- response = request("/api/v1/accounts/#{uid}/watch?address=#{watcher_url || WidgitAccountsSdk.configuration.watch_webhook_url}")
61
- return failed(response['error']) if response['status'] == 'failure'
60
+ watcher_url = watcher_url || WidgitAccountsSdk.configuration.watch_webhook_url
61
+ response = request("/api/v1/accounts/#{uid}/watch?#{watcher_url.to_query(:address)}")
62
+ return failed(response['error']) if response['status'] == 'failed'
62
63
  return response
63
64
  end
64
65
 
@@ -85,7 +86,7 @@ module WidgitAccountsSdk
85
86
  begin
86
87
  http.start do
87
88
  res = http.request(req)
88
- JSON.parse(res.body)
89
+ JSON.parse(res.body).merge('code' => res.code.to_i)
89
90
  end
90
91
  rescue => e
91
92
  return failed(e)
@@ -93,11 +94,11 @@ module WidgitAccountsSdk
93
94
  end
94
95
 
95
96
  def failed(e)
96
- { 'status' => 'failed', 'error' => e }
97
+ { 'status' => 'failed', 'error' => e, 'code' => 500 }
97
98
  end
98
99
 
99
100
  def success
100
- { 'status' => 'success' }
101
+ { 'status' => 'success', 'code' => 200 }
101
102
  end
102
103
  end
103
104
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: widgit_accounts_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stu Wright
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-06-21 00:00:00.000000000 Z
12
+ date: 2023-08-02 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A Ruby client for interacting with the Widgit Accounts API
15
15
  email: james.sherriff@widgit.com