widgit_accounts_sdk 0.0.4 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/widgit_accounts_sdk/client.rb +12 -11
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e86d598f05cce8432a51cfcbe65cb94c8778c47cd64105fb0e4d31447fbaf9f5
|
4
|
+
data.tar.gz: c3d709020421e239a22e157a3a3dd1e382ad27ac78b74d49bf5fa89c15c7edbd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03db3def928738a18e1f0690a1673a3bd19a8bb9160a5449986ff65cbdb17590e609c7fde5b657bc7276fb51adda7740b16cca37a31357742133a2da9a5597e1
|
7
|
+
data.tar.gz: 203f35427c3ad47ddac74e1ff34077c3a1195a7316406d500d95898015520c244268c9f2522c2dec300787ee6636a94a3ee6bec2629b5918e8f81bca4a309701
|
@@ -7,34 +7,35 @@ module WidgitAccountsSdk
|
|
7
7
|
|
8
8
|
def find_with_uid(uid)
|
9
9
|
response = request("/api/v1/accounts?#{uid.to_query(:uid)}")
|
10
|
-
return failed(response['error']) if response['status'] == '
|
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
15
|
response = request("/api/v1/accounts?#{email.to_query(:email)}")
|
16
|
-
return failed(response['error']) if response['status'] == '
|
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
21
|
response = request("/api/v1/accounts?#{username.to_query(:username)}")
|
22
|
-
return failed(response['error']) if response['status'] == '
|
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
27
|
response = request("/api/v1/accounts/check?#{email.to_query(:email)}")
|
28
|
-
return failed(response['error']) if response['status'] == '
|
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
|
+
email = CGI.escape email # URL encode the string, for things like plus forwarding which get converted to spaces
|
33
34
|
request_url = "/api/v1/accounts/invite?#{email.to_query(:email)}"
|
34
35
|
request_url += "&#{first_name.to_query(:first_name)}" if first_name
|
35
36
|
request_url += "&#{last_name.to_query(:last_name)}" if last_name
|
36
37
|
response = request(request_url, :post)
|
37
|
-
return failed(response['error']) if response['status'] == '
|
38
|
+
return failed(response['error']) if response['status'] == 'failed'
|
38
39
|
return response
|
39
40
|
end
|
40
41
|
|
@@ -46,20 +47,20 @@ module WidgitAccountsSdk
|
|
46
47
|
|
47
48
|
def create_account(params)
|
48
49
|
response = request("/api/v1/accounts", :post, params)
|
49
|
-
return failed(response['error']) if response['status'] == '
|
50
|
+
return failed(response['error']) if response['status'] == 'failed'
|
50
51
|
return response
|
51
52
|
end
|
52
53
|
|
53
54
|
def update_account(uid, params)
|
54
55
|
response = request("/api/v1/accounts/#{uid}", :patch, params)
|
55
|
-
return failed(response['error']) if response['status'] == '
|
56
|
+
return failed(response['error']) if response['status'] == 'failed'
|
56
57
|
return response
|
57
58
|
end
|
58
59
|
|
59
60
|
def watch(uid, watcher_url = nil)
|
60
61
|
watcher_url = watcher_url || WidgitAccountsSdk.configuration.watch_webhook_url
|
61
62
|
response = request("/api/v1/accounts/#{uid}/watch?#{watcher_url.to_query(:address)}")
|
62
|
-
return failed(response['error']) if response['status'] == '
|
63
|
+
return failed(response['error']) if response['status'] == 'failed'
|
63
64
|
return response
|
64
65
|
end
|
65
66
|
|
@@ -86,7 +87,7 @@ module WidgitAccountsSdk
|
|
86
87
|
begin
|
87
88
|
http.start do
|
88
89
|
res = http.request(req)
|
89
|
-
JSON.parse(res.body)
|
90
|
+
JSON.parse(res.body).merge('code' => res.code.to_i)
|
90
91
|
end
|
91
92
|
rescue => e
|
92
93
|
return failed(e)
|
@@ -94,11 +95,11 @@ module WidgitAccountsSdk
|
|
94
95
|
end
|
95
96
|
|
96
97
|
def failed(e)
|
97
|
-
{ 'status' => 'failed', 'error' => e }
|
98
|
+
{ 'status' => 'failed', 'error' => e, 'code' => 500 }
|
98
99
|
end
|
99
100
|
|
100
101
|
def success
|
101
|
-
{ 'status' => 'success' }
|
102
|
+
{ 'status' => 'success', 'code' => 200 }
|
102
103
|
end
|
103
104
|
end
|
104
105
|
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.
|
4
|
+
version: 0.0.6
|
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-
|
12
|
+
date: 2023-11-16 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
|
@@ -38,7 +38,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
version: '0'
|
40
40
|
requirements: []
|
41
|
-
rubygems_version: 3.3.
|
41
|
+
rubygems_version: 3.3.7
|
42
42
|
signing_key:
|
43
43
|
specification_version: 4
|
44
44
|
summary: Widgit Accounts API Client Ruby Gem
|