fulcrum 0.9.0 → 0.9.1
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/lib/fulcrum/client.rb +3 -4
- data/lib/fulcrum/version.rb +1 -1
- data/spec/lib/client_spec.rb +13 -10
- data/spec/resource_examples.rb +0 -2
- data/spec/spec_helper.rb +1 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6da67d577a8e64b2f9a92ea5360b370e78f1fb253a1e1029f07b2c2c756fc05
|
4
|
+
data.tar.gz: 65684be4fc3cd0ec36b8f9a17b97d42e2f4e2664c8b29d4e611e321e6a8f150d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a78d0a12e1a5c7a1f57de8556271b3ad0733fdda72fb0ea3d2d4e41284c1b3fc255a7c03686a0cca22d3c12f59ef0edb4cb1145f36bec3ffb31cfc0bb21aac24
|
7
|
+
data.tar.gz: a9107b8ce100e57f2b0a7958519b4b3781deb32b36f72378ff09f918e400ab8a0b653b0b29424e3fe5e6bb3640715650124e390ebf95b908f682530a9e361366
|
data/lib/fulcrum/client.rb
CHANGED
@@ -2,9 +2,7 @@ require 'faraday'
|
|
2
2
|
require 'faraday_middleware'
|
3
3
|
|
4
4
|
module Fulcrum
|
5
|
-
|
6
5
|
class Client
|
7
|
-
|
8
6
|
DEFAULT_URL = 'https://api.fulcrumapp.com/api/v2'
|
9
7
|
|
10
8
|
DEFAULT_USER_AGENT = "Fulcrum Ruby API Client, Version #{Fulcrum::VERSION}"
|
@@ -62,6 +60,7 @@ module Fulcrum
|
|
62
60
|
connection.basic_auth(username, password)
|
63
61
|
|
64
62
|
resp = connection.get('users.json')
|
63
|
+
|
65
64
|
user = resp.body['user']
|
66
65
|
user['contexts'] = user['contexts'].map{|c| c.except!('api_token')}
|
67
66
|
|
@@ -82,8 +81,8 @@ module Fulcrum
|
|
82
81
|
|
83
82
|
def self.create_connection(url, key = nil)
|
84
83
|
Faraday.new(url) do |connection|
|
85
|
-
connection.request
|
86
|
-
connection.request
|
84
|
+
connection.request :multipart
|
85
|
+
connection.request :json
|
87
86
|
|
88
87
|
connection.response :raise_error
|
89
88
|
connection.response :json, content_type: 'application/json'
|
data/lib/fulcrum/version.rb
CHANGED
data/spec/lib/client_spec.rb
CHANGED
@@ -23,14 +23,15 @@ describe Fulcrum::Client do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'can get_user' do
|
26
|
-
url = 'https://fred%40flinstones.com:secret@api.fulcrumapp.com/api/v2/users.json'
|
27
26
|
response = '{"user":{"first_name":"Jason","last_name":"Sanford","email":"jason@fulcrumapp.com","image_small":"https://fulcrumapp-dev.s3.amazonaws.com/user-images/small_abc.jpg","image_large":"https://fulcrumapp-dev.s3.amazonaws.com/user-images/large_abc.jpg","id":"49d06ce5-1457-476c-9cb4-fd9d41ea43ef","contexts":[{"name":"Team Jason","id":"e09c1a03-819d-47d6-aebc-f8712d292b57","api_token":"abc123","image_small":"https://fulcrumapp-dev.s3.amazonaws.com/organization-images/small_abc.jpg","image_large":"https://fulcrumapp-dev.s3.amazonaws.com/organization-images/large_abc.jpg","type":"organization","role":{},"domain":null,"plan":{}}],"access":{"allowed":true}}}'
|
28
27
|
|
29
|
-
stub_request(:get,
|
30
|
-
.
|
31
|
-
|
28
|
+
stub_request(:get, "https://api.fulcrumapp.com/api/v2/users.json")
|
29
|
+
.with(
|
30
|
+
headers: {
|
31
|
+
'Authorization' => 'Basic ZnJlZEBmbGluc3RvbmVzLmNvbTpzZWNyZXQ='
|
32
|
+
}
|
33
|
+
).to_return(status: 200, body: response, headers: { 'Content-Type'=>'application/json' })
|
32
34
|
|
33
|
-
sql = 'select name from tables limit 1;'
|
34
35
|
user = Fulcrum::Client.get_user('fred@flinstones.com', 'secret')
|
35
36
|
|
36
37
|
expect(user['contexts'].length).to eq(1)
|
@@ -38,14 +39,16 @@ describe Fulcrum::Client do
|
|
38
39
|
end
|
39
40
|
|
40
41
|
it 'can create_authorization' do
|
41
|
-
url = 'https://fred%40flinstones.com:secret@api.fulcrumapp.com/api/v2/authorizations.json'
|
42
42
|
body = '{"authorization":{"organization_id":"abc-123","note":"Tess Ting","timeout":null,"user_id":null}}'
|
43
43
|
response = '{"authorization":{"note":"Tess Ting","expires_at":null,"timeout":null,"token_last_8":"46c5cb33","last_ip_address":null,"last_user_agent":null,"token":"ac493349cd4de0c376185c1d347d24ce5a3867bd3e04397bb875ed6b9b0546b768caa3bf46c5cb33","created_at":"2019-04-12T13:25:28Z","updated_at":"2019-04-12T13:25:28Z","id":"f1d84caa-da28-4fc5-a341-44bb9efa6266","last_used_at":null,"user_id":"4f1cfa091441405373000443"}}'
|
44
44
|
|
45
|
-
stub_request(:post,
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
stub_request(:post, "https://api.fulcrumapp.com/api/v2/authorizations.json").
|
46
|
+
with(
|
47
|
+
body: body,
|
48
|
+
headers: {
|
49
|
+
'Authorization' => 'Basic ZnJlZEBmbGluc3RvbmVzLmNvbTpzZWNyZXQ='
|
50
|
+
}
|
51
|
+
).to_return(status: 200, body: response, headers: { 'Content-Type'=>'application/json' })
|
49
52
|
|
50
53
|
authorization = Fulcrum::Client.create_authorization('fred@flinstones.com', 'secret', 'abc-123', 'Tess Ting')
|
51
54
|
|
data/spec/resource_examples.rb
CHANGED
data/spec/spec_helper.rb
CHANGED