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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ef9b7218a056ee7770b20a9a6701907c7972febccfb1c11850ca02b2e6190932
4
- data.tar.gz: 867da58f1eefccedcb9e48ebea1146bc79351e6c5b07f96fb127e0f493c2d60d
3
+ metadata.gz: e6fcc8c9485845928ca1e342cd880ebcb100dc00b1af03b952060b11b5200fea
4
+ data.tar.gz: eef5e1df64234fb140791f2fe057aeaff43950b2ad6ba5f45eee43e7c1bbcefa
5
5
  SHA512:
6
- metadata.gz: 46d20a9bedd7e7c7ef82b91b07b842b44ef8be7fca7d777b1e4223f7a8d9bebb41465533a78b1a44965ad3b490960b95e974b54b6ddf75b460957fa9883b7fb3
7
- data.tar.gz: 056a147b56301321efeeb7d0324e2cd410301887a0fa6780c25251a31fa0a0dd5b8fc002c371b9507ddb15956eb4253e5f7b10613c7df40c97dc5ef700f8a9b0
6
+ metadata.gz: 3cfe3f96030f00ca6fece9c148ed1868522a132af46df5c1b0414e1c367c7da89eafbe7464c1e1577588af9886cea7fb3a012ed87c0df07831cebd71f7c485ed
7
+ data.tar.gz: 7d86a8f52524e250245657a1d5ed080d20b230f79748cbf5ec0ee7b989b5ef55c6d08f5f80885f46a188f654265dac1eadb91af87dde0da2639e4f882918eb2b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- octadesk_api (0.1.1)
4
+ octadesk_api (0.1.2)
5
5
  httparty (= 0.15.6)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,43 +1,73 @@
1
1
  # OctadeskApi
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/octadesk_api`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Gem para comunicação com o www.octadesk.com
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ ## Instalação
6
6
 
7
- ## Installation
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
- And then execute:
13
+ e então rodar o comando
16
14
 
17
- $ bundle
15
+ $ bundle install
18
16
 
19
- Or install it yourself as:
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
- ## Contributing
34
-
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/octadesk_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
-
37
- ## License
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
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
37
+ ### Cliente
38
+ ```ruby
39
+ client = OctadeskApi::Client.new('token')
40
+ ```
40
41
 
41
- ## Code of Conduct
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
- Everyone interacting in the OctadeskApi project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/octadesk_api/blob/master/CODE_OF_CONDUCT.md).
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
- attr_accessor :access_key, :env
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...
@@ -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
@@ -0,0 +1,10 @@
1
+ module OctadeskApi
2
+ class Configuration
3
+ attr_accessor :access_key, :env
4
+ def initialize
5
+ @access_key = nil
6
+ @env = nil
7
+ end
8
+
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  module OctadeskApi
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
data/octadesk_api.gemspec CHANGED
@@ -29,5 +29,6 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency "rspec", "~> 3.0"
30
30
 
31
31
  spec.add_dependency "httparty", "0.15.6"
32
+ spec.add_dependency 'activesupport'
32
33
 
33
34
  end
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.2
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-05-03 00:00:00.000000000 Z
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