octadesk_api 0.1.2 → 0.1.3
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 +1 -1
- data/README.md +55 -25
- data/lib/octadesk_api.rb +7 -1
- data/lib/octadesk_api/client.rb +6 -1
- data/lib/octadesk_api/client/ticket_api.rb +31 -0
- data/lib/octadesk_api/configuration.rb +10 -0
- data/lib/octadesk_api/version.rb +1 -1
- data/octadesk_api.gemspec +1 -0
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6fcc8c9485845928ca1e342cd880ebcb100dc00b1af03b952060b11b5200fea
|
4
|
+
data.tar.gz: eef5e1df64234fb140791f2fe057aeaff43950b2ad6ba5f45eee43e7c1bbcefa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3cfe3f96030f00ca6fece9c148ed1868522a132af46df5c1b0414e1c367c7da89eafbe7464c1e1577588af9886cea7fb3a012ed87c0df07831cebd71f7c485ed
|
7
|
+
data.tar.gz: 7d86a8f52524e250245657a1d5ed080d20b230f79748cbf5ec0ee7b989b5ef55c6d08f5f80885f46a188f654265dac1eadb91af87dde0da2639e4f882918eb2b
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,43 +1,73 @@
|
|
1
1
|
# OctadeskApi
|
2
2
|
|
3
|
-
|
3
|
+
Gem para comunicação com o www.octadesk.com
|
4
4
|
|
5
|
-
|
5
|
+
## Instalação
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
Add this line to your application's Gemfile:
|
7
|
+
Adicionar esta linha ao seu arquivo Gemfile
|
10
8
|
|
11
9
|
```ruby
|
12
10
|
gem 'octadesk_api'
|
13
11
|
```
|
14
12
|
|
15
|
-
|
13
|
+
e então rodar o comando
|
16
14
|
|
17
|
-
$ bundle
|
15
|
+
$ bundle install
|
18
16
|
|
19
|
-
|
17
|
+
Para apenas instalar
|
20
18
|
|
21
19
|
$ gem install octadesk_api
|
22
20
|
|
23
|
-
## Usage
|
24
|
-
|
25
|
-
TODO: Write usage instructions here
|
26
|
-
|
27
|
-
## Development
|
28
|
-
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
-
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
21
|
|
33
|
-
##
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
22
|
+
## Configurar
|
23
|
+
Adicionar a variavel de ambiente
|
24
|
+
```ruby
|
25
|
+
ENV['OCTADESK_ACCESS_TOKEN']
|
26
|
+
```
|
27
|
+
Ou
|
28
|
+
```ruby
|
29
|
+
OctadeskApi::Client.new(access_token)
|
30
|
+
```
|
31
|
+
Ou
|
32
|
+
```ruby
|
33
|
+
OctadeskApi.access_token = 'token'
|
34
|
+
```
|
35
|
+
## Como Usar?
|
38
36
|
|
39
|
-
|
37
|
+
### Cliente
|
38
|
+
```ruby
|
39
|
+
client = OctadeskApi::Client.new('token')
|
40
|
+
```
|
40
41
|
|
41
|
-
|
42
|
+
### Pessoas
|
43
|
+
```ruby
|
44
|
+
client = OctadeskApi::Client.new('token')
|
45
|
+
client.persons.find(id)
|
46
|
+
client.persons.find_by_email('email@email.com.br')
|
47
|
+
client.persons.where({email: 'email@email.com.br'})
|
48
|
+
client.persons.create({name: 'Pessoa', email: 'email@email.com.br'})
|
49
|
+
client.persons.update({name: 'Pessoa Nome', email: 'email@email.com.br'})
|
50
|
+
```
|
42
51
|
|
43
|
-
|
52
|
+
#### Cadastrando novos usuarios
|
53
|
+
```ruby
|
54
|
+
client = OctadeskApi::Client.new(ENV['OCTADESK_ACCESS_TOKEN'])
|
55
|
+
client.persons.create({
|
56
|
+
email: 'email@emailcom.br',
|
57
|
+
phoneContacts: {
|
58
|
+
number: '99123-1234'
|
59
|
+
},
|
60
|
+
organization: {
|
61
|
+
name: 'new client'
|
62
|
+
}
|
63
|
+
})
|
64
|
+
```
|
65
|
+
|
66
|
+
### Organização
|
67
|
+
```ruby
|
68
|
+
client = OctadeskApi::Client.new('token')
|
69
|
+
client.organizations.find(id)
|
70
|
+
client.organizations.where({name: 'Name'})
|
71
|
+
client.organizations.create({name: 'Pessoa'})
|
72
|
+
client.organizations.update('id', {name: 'Pessoa Nome'})
|
73
|
+
```
|
data/lib/octadesk_api.rb
CHANGED
@@ -1,13 +1,19 @@
|
|
1
1
|
require "httparty"
|
2
2
|
require "octadesk_api/version"
|
3
3
|
require "octadesk_api/client"
|
4
|
+
require "octadesk_api/configuration"
|
5
|
+
require 'active_support/core_ext/module/delegation'
|
4
6
|
|
5
7
|
module OctadeskApi
|
6
8
|
class << self
|
7
|
-
|
9
|
+
delegate :env, :env=, :access_key, :access_key=, to: :configuration
|
8
10
|
def production?
|
9
11
|
ENV['RAILS_ENV'] == 'production' || self.env == 'production'
|
10
12
|
end
|
13
|
+
|
14
|
+
def configuration
|
15
|
+
@configuration ||= Configuration.new
|
16
|
+
end
|
11
17
|
end
|
12
18
|
class Error < StandardError; end
|
13
19
|
# Your code goes here...
|
data/lib/octadesk_api/client.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'octadesk_api/client/person_api'
|
2
|
+
require 'octadesk_api/client/ticket_api'
|
2
3
|
require 'octadesk_api/client/organization_api'
|
3
4
|
require 'octadesk_api/errors'
|
4
5
|
module OctadeskApi
|
@@ -8,7 +9,7 @@ module OctadeskApi
|
|
8
9
|
def initialize access_token = nil
|
9
10
|
@access_token = access_token || OctadeskApi.access_key || ENV['OCTADESK_ACCESS_TOKEN']
|
10
11
|
raise OctadeskApi::MissingTokenError unless @access_token
|
11
|
-
self.class.default_options.merge!(headers: { 'Authorization' => "Bearer #{access_token}", 'Content-Type' => 'application/json'}, verify: OctadeskApi.production? )
|
12
|
+
self.class.default_options.merge!(headers: { 'Authorization' => "Bearer #{@access_token}", 'Content-Type' => 'application/json'}, verify: OctadeskApi.production? )
|
12
13
|
end
|
13
14
|
|
14
15
|
def perform_request(path)
|
@@ -23,6 +24,10 @@ module OctadeskApi
|
|
23
24
|
def organizations
|
24
25
|
@organizations_client ||= OrganizationApi.new(self)
|
25
26
|
end
|
27
|
+
|
28
|
+
def tickets
|
29
|
+
@tickets_client ||= TicketApi.new(self)
|
30
|
+
end
|
26
31
|
|
27
32
|
def get(path, options = {})
|
28
33
|
self.class.get(path, options)
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module OctadeskApi
|
2
|
+
class Client
|
3
|
+
class TicketApi
|
4
|
+
attr_accessor :client
|
5
|
+
def initialize(client)
|
6
|
+
self.client = client
|
7
|
+
end
|
8
|
+
|
9
|
+
def find(id)
|
10
|
+
response = client.get("/tickets/#{id}")
|
11
|
+
response.parsed_response
|
12
|
+
end
|
13
|
+
|
14
|
+
def where(options = {})
|
15
|
+
response = client.post("/tickets", options)
|
16
|
+
response.parsed_response
|
17
|
+
end
|
18
|
+
|
19
|
+
def create(options = {})
|
20
|
+
response = client.post("/tickets", options)
|
21
|
+
response.parsed_response
|
22
|
+
end
|
23
|
+
|
24
|
+
def update(id, options = {})
|
25
|
+
response = client.put("/tickets/#{id}", options)
|
26
|
+
response.parsed_response
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
data/lib/octadesk_api/version.rb
CHANGED
data/octadesk_api.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sidnei Pacheco
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 0.15.6
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: activesupport
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
description: Octadesk.com api client
|
70
84
|
email:
|
71
85
|
- sidneip.junior@gmail.com
|
@@ -88,6 +102,8 @@ files:
|
|
88
102
|
- lib/octadesk_api/client.rb
|
89
103
|
- lib/octadesk_api/client/organization_api.rb
|
90
104
|
- lib/octadesk_api/client/person_api.rb
|
105
|
+
- lib/octadesk_api/client/ticket_api.rb
|
106
|
+
- lib/octadesk_api/configuration.rb
|
91
107
|
- lib/octadesk_api/errors.rb
|
92
108
|
- lib/octadesk_api/version.rb
|
93
109
|
- octadesk_api.gemspec
|