octadesk_api 0.1.0 → 0.1.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/Gemfile.lock +39 -0
- data/lib/octadesk_api/client.rb +44 -0
- data/lib/octadesk_api/client/organization_api.rb +32 -0
- data/lib/octadesk_api/client/person_api.rb +36 -0
- data/lib/octadesk_api/errors.rb +10 -0
- data/lib/octadesk_api/version.rb +1 -1
- data/octadesk_api-0.1.0.gem +0 -0
- metadata +7 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82ced1ad9c7fd8e34a46719e3694bd19be873f311e2577cab08dc108113200d1
|
4
|
+
data.tar.gz: 1abb0839876c412354de50875d04682c81bb6464b0e3492322f25c7abfb10961
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25612c6ba9739b4fdb2cf2a861b2cd0068991ff3342fb10b77d917d4eba4ccf8c3a4178aa9efc2abf5cd60c996ddd2dcbc8e9b08a125b3f53bc981326754a3b3
|
7
|
+
data.tar.gz: ae6ffceed01dae41e5a39ee1da04943299729405c1afa1c963c90d0fa79e8476cebddec616af8b10ea4cf6bdfbbd5d4b4c4162569a8407acbbbbefa2fbaf7c79
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
octadesk_api (0.1.0)
|
5
|
+
httparty (= 0.15.6)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.3)
|
11
|
+
httparty (0.15.6)
|
12
|
+
multi_xml (>= 0.5.2)
|
13
|
+
multi_xml (0.6.0)
|
14
|
+
rake (10.5.0)
|
15
|
+
rspec (3.8.0)
|
16
|
+
rspec-core (~> 3.8.0)
|
17
|
+
rspec-expectations (~> 3.8.0)
|
18
|
+
rspec-mocks (~> 3.8.0)
|
19
|
+
rspec-core (3.8.0)
|
20
|
+
rspec-support (~> 3.8.0)
|
21
|
+
rspec-expectations (3.8.3)
|
22
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
23
|
+
rspec-support (~> 3.8.0)
|
24
|
+
rspec-mocks (3.8.0)
|
25
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
26
|
+
rspec-support (~> 3.8.0)
|
27
|
+
rspec-support (3.8.0)
|
28
|
+
|
29
|
+
PLATFORMS
|
30
|
+
ruby
|
31
|
+
|
32
|
+
DEPENDENCIES
|
33
|
+
bundler (~> 1.17)
|
34
|
+
octadesk_api!
|
35
|
+
rake (~> 10.0)
|
36
|
+
rspec (~> 3.0)
|
37
|
+
|
38
|
+
BUNDLED WITH
|
39
|
+
1.17.3
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'octadesk_api/client/person_api'
|
2
|
+
require 'octadesk_api/client/organization_api'
|
3
|
+
require 'octadesk_api/errors'
|
4
|
+
module OctadeskApi
|
5
|
+
class Client
|
6
|
+
include HTTParty
|
7
|
+
base_uri "https://api.octadesk.services"
|
8
|
+
def initialize access_token = nil
|
9
|
+
@access_token = access_token || OctadeskApi.access_key || ENV['OCTADESK_ACCESS_TOKEN']
|
10
|
+
raise OctadeskApi::MissingTokenError unless @access_token
|
11
|
+
self.class.default_options.merge!(headers: { 'Authorization' => "Bearer #{access_token}", 'Content-Type' => 'application/json' } )
|
12
|
+
end
|
13
|
+
|
14
|
+
def perform_request(path)
|
15
|
+
response = self.class.get(path)
|
16
|
+
response
|
17
|
+
end
|
18
|
+
|
19
|
+
def persons
|
20
|
+
@person_client ||= PersonApi.new(self)
|
21
|
+
end
|
22
|
+
|
23
|
+
def organizations
|
24
|
+
@organizations_client ||= OrganizationApi.new(self)
|
25
|
+
end
|
26
|
+
|
27
|
+
def get(path, options = {})
|
28
|
+
self.class.get(path, options)
|
29
|
+
end
|
30
|
+
|
31
|
+
def post(path, options = {})
|
32
|
+
self.class.post(path, body: options.to_json, headers: default_headers)
|
33
|
+
end
|
34
|
+
|
35
|
+
def put(path, options = {})
|
36
|
+
self.class.put(path, body: options.to_json, headers: default_headers)
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
def default_headers
|
41
|
+
{ 'Content-Type' => 'application/json' }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
|
2
|
+
module OctadeskApi
|
3
|
+
class Client
|
4
|
+
class OrganizationApi
|
5
|
+
attr_accessor :client
|
6
|
+
def initialize(client)
|
7
|
+
self.client = client
|
8
|
+
end
|
9
|
+
|
10
|
+
def find(id)
|
11
|
+
response = client.get("/organizations/#{id}")
|
12
|
+
response.parsed_response
|
13
|
+
end
|
14
|
+
|
15
|
+
def where(options = {})
|
16
|
+
response = client.get("/organizations", options)
|
17
|
+
response.parsed_response
|
18
|
+
end
|
19
|
+
|
20
|
+
def create(options = {})
|
21
|
+
response = client.post("/organizations", options)
|
22
|
+
response.parsed_response
|
23
|
+
end
|
24
|
+
|
25
|
+
def update(id, options = {})
|
26
|
+
response = client.put("/organizations/#{id}", options)
|
27
|
+
response.parsed_response
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module OctadeskApi
|
2
|
+
class Client
|
3
|
+
class PersonApi
|
4
|
+
attr_accessor :client
|
5
|
+
def initialize(client)
|
6
|
+
self.client = client
|
7
|
+
end
|
8
|
+
|
9
|
+
def find(id)
|
10
|
+
response = client.get("/persons/#{id}")
|
11
|
+
response.parsed_response
|
12
|
+
end
|
13
|
+
|
14
|
+
def find_by_email(email)
|
15
|
+
response = client.get("/persons/", {query: {email: email} })
|
16
|
+
response.parsed_response
|
17
|
+
end
|
18
|
+
|
19
|
+
def where(options = {})
|
20
|
+
response = client.post("/persons/filter", options)
|
21
|
+
response.parsed_response
|
22
|
+
end
|
23
|
+
|
24
|
+
def create(options = {})
|
25
|
+
response = client.post("/persons", options)
|
26
|
+
response.parsed_response
|
27
|
+
end
|
28
|
+
|
29
|
+
def update(id, options = {})
|
30
|
+
response = client.put("/persons/#{id}", options)
|
31
|
+
response.parsed_response
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
data/lib/octadesk_api/version.rb
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: octadesk_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sidnei Pacheco
|
@@ -78,13 +78,19 @@ files:
|
|
78
78
|
- ".travis.yml"
|
79
79
|
- CODE_OF_CONDUCT.md
|
80
80
|
- Gemfile
|
81
|
+
- Gemfile.lock
|
81
82
|
- LICENSE.txt
|
82
83
|
- README.md
|
83
84
|
- Rakefile
|
84
85
|
- bin/console
|
85
86
|
- bin/setup
|
86
87
|
- lib/octadesk_api.rb
|
88
|
+
- lib/octadesk_api/client.rb
|
89
|
+
- lib/octadesk_api/client/organization_api.rb
|
90
|
+
- lib/octadesk_api/client/person_api.rb
|
91
|
+
- lib/octadesk_api/errors.rb
|
87
92
|
- lib/octadesk_api/version.rb
|
93
|
+
- octadesk_api-0.1.0.gem
|
88
94
|
- octadesk_api.gemspec
|
89
95
|
homepage: https://github.com/sidneip/octadesk
|
90
96
|
licenses:
|