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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 01887a4994179bf97ae2466eab5199927b493000c462caaa0f79174649400fc7
4
- data.tar.gz: 65bd5cebbd6babd5f8a92ebe310d1e7f21ebf8a23b3b03773219aa2056dc38d4
3
+ metadata.gz: 82ced1ad9c7fd8e34a46719e3694bd19be873f311e2577cab08dc108113200d1
4
+ data.tar.gz: 1abb0839876c412354de50875d04682c81bb6464b0e3492322f25c7abfb10961
5
5
  SHA512:
6
- metadata.gz: d7f841488fe67370eec7e37c7fac4378a8b0c0102ed5a8730c8401b7a29e6420596269288bc3f58b5f97a214dd19275868ee495a68983dcdfcbf837e9084eca6
7
- data.tar.gz: 9aefb4a933f18894a4dbd4dff1c22154d8cd9bf1e2a4148f56c29e9fd79b11973c66d3005891e9727dcec9a7fca2d14db08ecb7bea5778670b787fe240ba736f
6
+ metadata.gz: 25612c6ba9739b4fdb2cf2a861b2cd0068991ff3342fb10b77d917d4eba4ccf8c3a4178aa9efc2abf5cd60c996ddd2dcbc8e9b08a125b3f53bc981326754a3b3
7
+ data.tar.gz: ae6ffceed01dae41e5a39ee1da04943299729405c1afa1c963c90d0fa79e8476cebddec616af8b10ea4cf6bdfbbd5d4b4c4162569a8407acbbbbefa2fbaf7c79
@@ -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
@@ -0,0 +1,10 @@
1
+ module OctadeskApi
2
+ class OctadeskError < StandardError
3
+ end
4
+
5
+ class MissingTokenError < OctadeskError
6
+ def message
7
+ "access_token is missing, try Octadesk.access_token = xyz"
8
+ end
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  module OctadeskApi
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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.0
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: