caplinked-api 0.2.0 → 0.3.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 +80 -1
- data/lib/caplinked/client.rb +5 -2
- data/lib/caplinked/request.rb +14 -2
- data/lib/caplinked/rest/users.rb +5 -0
- data/lib/caplinked/utils.rb +2 -2
- data/lib/caplinked/version.rb +1 -1
- metadata +16 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0d4531955ecae124eecdd22fa0f9fd60c7e4725
|
4
|
+
data.tar.gz: 29e7dfccd6fdd947a5834e344d00a6060e00c535
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51e08fdb619be01e391c385cb25618efd05eb403d29858c6548ef5763d311d550b715b24dce3ea16f74abe0e340a00cc0f3280c7b9f79b54d2ead54fdaa76082
|
7
|
+
data.tar.gz: 3f422623d166ad2036e3083b3bf9bb7b7f575f3c016155a30c17d6b95444114219bc09871cafe5f611b05feeba270708826002aec3c04aa179fe6512c0e688f9
|
data/README.md
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
Ruby SDK for Caplinked's API
|
4
4
|
Documentation at https://developer.caplinked.com/docs
|
5
5
|
|
6
|
+
Changelog at https://developer.caplinked.com/api-changelog
|
7
|
+
|
6
8
|
## Quick start guide:
|
7
9
|
|
8
10
|
Add Rubygem to Bundle:
|
@@ -14,7 +16,78 @@ gem 'caplinked-api'
|
|
14
16
|
Assign Client
|
15
17
|
|
16
18
|
```
|
17
|
-
client = Caplinked::Client.new
|
19
|
+
client = Caplinked::Client.new api_host: 'sandbox.caplinked.com', api_scheme: 'https'
|
20
|
+
|
21
|
+
client.api_key = 'YOUR_PUBLIC_API_KEY'
|
22
|
+
client.api_secret_key = 'YOUR_SECRET_API_KEY'
|
23
|
+
client.api_user_token = 'USER_RESOURCE_IDENTIFIER_TOKEN'
|
24
|
+
```
|
25
|
+
|
26
|
+
Get User Info
|
27
|
+
|
28
|
+
```
|
29
|
+
# Info about the current user (in this case John Smith, an organization admin)
|
30
|
+
|
31
|
+
client.get_user_info
|
32
|
+
|
33
|
+
# response
|
34
|
+
{
|
35
|
+
"id": 9818,
|
36
|
+
"first_name": "John",
|
37
|
+
"last_name": "Smith",
|
38
|
+
"email": "john@example.com",
|
39
|
+
"time_zone": "Pacific Time (US & Canada)",
|
40
|
+
"user_token": "fc39b9012e47a5713932094065e17fb7ab76e83d"
|
41
|
+
}
|
42
|
+
|
43
|
+
# As an organization admin, list all members of your organization
|
44
|
+
|
45
|
+
client.show_organization_members
|
46
|
+
|
47
|
+
# response
|
48
|
+
{
|
49
|
+
"users": [
|
50
|
+
{
|
51
|
+
"id": 9818,
|
52
|
+
"first_name": "John",
|
53
|
+
"last_name": "Smith",
|
54
|
+
"email": "john@example.com",
|
55
|
+
"time_zone": "Pacific Time (US & Canada)",
|
56
|
+
"user_token": "fc39b9012e47a5713932094065e17fb7ab76e83d"
|
57
|
+
"organization_admin": true
|
58
|
+
},
|
59
|
+
{
|
60
|
+
"id": 9820,
|
61
|
+
"first_name": "Jina",
|
62
|
+
"last_name": "Baker",
|
63
|
+
"email": "jina@example.com",
|
64
|
+
"time_zone": "Pacific Time (US & Canada)",
|
65
|
+
"user_token": "e05b83c6714120fb87a176241bc2031f22f5cf4a",
|
66
|
+
"organization_admin": false
|
67
|
+
}
|
68
|
+
]
|
69
|
+
}
|
70
|
+
```
|
71
|
+
|
72
|
+
Make API calls for a different user resource
|
73
|
+
|
74
|
+
```
|
75
|
+
# Switch to Jina's user token
|
76
|
+
|
77
|
+
client.api_user_token = 'e05b83c6714120fb87a176241bc2031f22f5cf4a'
|
78
|
+
|
79
|
+
client.get_user_info
|
80
|
+
|
81
|
+
# response
|
82
|
+
{
|
83
|
+
"id": 9820,
|
84
|
+
"first_name": "Jina",
|
85
|
+
"last_name": "Baker",
|
86
|
+
"email": "jina@example.com",
|
87
|
+
"time_zone": "Pacific Time (US & Canada)",
|
88
|
+
"user_token": "e05b83c6714120fb87a176241bc2031f22f5cf4a"
|
89
|
+
}
|
90
|
+
|
18
91
|
```
|
19
92
|
## Activities:
|
20
93
|
|
@@ -308,6 +381,12 @@ Update user
|
|
308
381
|
update_user = client.update_user user: { email: 'new email address'}
|
309
382
|
```
|
310
383
|
|
384
|
+
Delete user
|
385
|
+
|
386
|
+
```
|
387
|
+
result = client.delete_user user: { id: 32523 }
|
388
|
+
```
|
389
|
+
|
311
390
|
##Workspace
|
312
391
|
List all workspaces for a team
|
313
392
|
|
data/lib/caplinked/client.rb
CHANGED
@@ -9,12 +9,15 @@ module Caplinked
|
|
9
9
|
class Client
|
10
10
|
include Caplinked::Utils
|
11
11
|
include Caplinked::REST::API
|
12
|
-
attr_accessor :api_key, :api_host, :api_scheme
|
12
|
+
attr_accessor :api_key, :api_secret_key, :api_user_token, :api_host, :api_scheme
|
13
13
|
|
14
14
|
# Usage:
|
15
15
|
# client = Caplinked::Client.new api_key: '...', api_host: 'sandbox.caplinked.com'
|
16
|
-
# client.upload_file file_name: '...',
|
16
|
+
# client.upload_file file_name: '...',
|
17
17
|
def initialize(options = {})
|
18
|
+
options[:api_key] ||= ''
|
19
|
+
options[:api_secret_key] ||= ''
|
20
|
+
options[:api_user_token] ||= ''
|
18
21
|
options[:api_host] ||= 'sandbox.caplinked.com'
|
19
22
|
options[:api_scheme] ||= 'https'
|
20
23
|
|
data/lib/caplinked/request.rb
CHANGED
@@ -16,15 +16,27 @@ module Caplinked
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def perform
|
19
|
-
headers = (@options.delete(:headers) || {}).merge('X-Token' => @client.api_key)
|
20
19
|
@uri.query_values = @options.delete(:params)
|
21
|
-
response = HTTP.headers(
|
20
|
+
response = HTTP.headers(req_headers).request(@request_method, @uri.to_s, @options)
|
22
21
|
response_body = response.body.empty? ? '' : change_keys_to_symbols(response.parse)
|
23
22
|
response_headers = response.headers
|
24
23
|
fail_or_return_response_body(response.code, response_body, response_headers)
|
25
24
|
end
|
26
25
|
|
27
26
|
private
|
27
|
+
|
28
|
+
def req_headers
|
29
|
+
expiration = 5.minutes.from_now.utc.to_s
|
30
|
+
signature = "Method=HMAC-SHA256 Signature=" + OpenSSL::HMAC.hexdigest('SHA256', @client.api_secret_key, [@client.api_key.to_s, @client.api_user_token.to_s,expiration].join)
|
31
|
+
default_headers = {
|
32
|
+
'x-api-key' => @client.api_key,
|
33
|
+
'x-api-user-token' => @client.api_user_token,
|
34
|
+
'x-api-exp-date' => expiration,
|
35
|
+
'x-api-signature' => signature
|
36
|
+
}
|
37
|
+
(@options.delete(:headers) || {}).merge(default_headers)
|
38
|
+
end
|
39
|
+
|
28
40
|
def change_keys_to_symbols(parsed_response)
|
29
41
|
if parsed_response.is_a?(Hash)
|
30
42
|
parsed_response.deep_symbolize_keys
|
data/lib/caplinked/rest/users.rb
CHANGED
@@ -16,6 +16,11 @@ module Caplinked
|
|
16
16
|
perform_put('/api/v1/users/me', nil, body.to_json, {'Content-Type' => 'application/json'} )
|
17
17
|
end
|
18
18
|
|
19
|
+
def delete_user(options = {})
|
20
|
+
body = options.stringify_keys.slice('user')
|
21
|
+
perform_delete('/api/v1/users', nil, body.to_json, {'Content-Type' => 'application/json'})
|
22
|
+
end
|
23
|
+
|
19
24
|
end
|
20
25
|
end
|
21
26
|
end
|
data/lib/caplinked/utils.rb
CHANGED
@@ -8,8 +8,8 @@ module Caplinked
|
|
8
8
|
perform_request(:get, path, { params: params })
|
9
9
|
end
|
10
10
|
|
11
|
-
def perform_delete(path, params = {})
|
12
|
-
perform_request(:delete, path, { params: params })
|
11
|
+
def perform_delete(path, params = {}, body = {}, headers = {})
|
12
|
+
perform_request(:delete, path, { params: params, body: body, headers: headers })
|
13
13
|
end
|
14
14
|
|
15
15
|
def perform_put(path, params = {}, body = {}, headers = {})
|
data/lib/caplinked/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: caplinked-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jordan Fowler
|
@@ -9,76 +9,76 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-02-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '4.0'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '4.0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: addressable
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- - ~>
|
32
|
+
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '2.3'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- - ~>
|
39
|
+
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '2.3'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: http
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - ~>
|
46
|
+
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '2.0'
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- - ~>
|
53
|
+
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '2.0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: http-form_data
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- - ~>
|
60
|
+
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '1.0'
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- - ~>
|
67
|
+
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '1.0'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: bundler
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- - ~>
|
74
|
+
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: '1.0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
|
-
- - ~>
|
81
|
+
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '1.0'
|
84
84
|
description: Ruby SDK for Caplinked's API.
|
@@ -90,6 +90,7 @@ extra_rdoc_files: []
|
|
90
90
|
files:
|
91
91
|
- README.md
|
92
92
|
- caplinked-api.gemspec
|
93
|
+
- lib/caplinked-api.rb
|
93
94
|
- lib/caplinked/client.rb
|
94
95
|
- lib/caplinked/error.rb
|
95
96
|
- lib/caplinked/request.rb
|
@@ -106,7 +107,6 @@ files:
|
|
106
107
|
- lib/caplinked/rest/workspaces.rb
|
107
108
|
- lib/caplinked/utils.rb
|
108
109
|
- lib/caplinked/version.rb
|
109
|
-
- lib/caplinked-api.rb
|
110
110
|
homepage: https://github.com/caplinked/caplinked-api-ruby
|
111
111
|
licenses:
|
112
112
|
- MIT
|
@@ -117,17 +117,17 @@ require_paths:
|
|
117
117
|
- lib
|
118
118
|
required_ruby_version: !ruby/object:Gem::Requirement
|
119
119
|
requirements:
|
120
|
-
- -
|
120
|
+
- - ">="
|
121
121
|
- !ruby/object:Gem::Version
|
122
122
|
version: 1.9.3
|
123
123
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
124
|
requirements:
|
125
|
-
- -
|
125
|
+
- - ">="
|
126
126
|
- !ruby/object:Gem::Version
|
127
127
|
version: '0'
|
128
128
|
requirements: []
|
129
129
|
rubyforge_project:
|
130
|
-
rubygems_version: 2.
|
130
|
+
rubygems_version: 2.4.5
|
131
131
|
signing_key:
|
132
132
|
specification_version: 4
|
133
133
|
summary: Ruby SDK for Caplinked's API.
|