groovehq 1.0.4 → 1.0.5

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
  SHA1:
3
- metadata.gz: 5caa9a0d2a902caf7958fa35caecf3daf7e04981
4
- data.tar.gz: ce1ebc9948fb37355fc6c66eb853495b97add9f1
3
+ metadata.gz: e61b3bab09b188fd2d9c2f1aad3dead54143be4b
4
+ data.tar.gz: a2c9ce9160d98b446c0ab415f473b1e7c7a267f8
5
5
  SHA512:
6
- metadata.gz: 2ed65e73f939c6f5df34ef9771ef2e38594edb0a788f3c1f911b7d5287f301db4e04b2eab0fe1e5e31edce9d2be47e39c57395b0724d5694e62eeb8dc7318455
7
- data.tar.gz: 7af00f027964dd04d543e7c25b7efd435415a5ddce342895588e7b04898f02dfcc0e9c6fe35d65489790e214e9f9bba4d1b9a5401e193f02741701898cce56f6
6
+ metadata.gz: d57eacb85e4bd8b1855bbcbcce1e80641ff9bfdb1501fa8e344b7153320676d9ff415445f54ed7e978bc0f8066facf3448846ac9b4a2888e121f476d876061b2
7
+ data.tar.gz: ecdc813e58dfd8a11e7eca21748aa910ffddd9c26f217892a071a47dec23b0d377d82746ee3ce41d6fc7956b15abcb2261557a691a9845e50e9a098c2f90a641
@@ -1,5 +1,7 @@
1
1
  language: ruby
2
2
  cache: bundler
3
- script: bundle exec rspec spec
3
+ script: bundle exec rake spec
4
4
  rvm:
5
5
  - 2.1.4
6
+ env:
7
+ secure: "NiB0KwycVqFejW4SIK6bOlrFJMK00gUbPIQMWM59pmmM8NXjLrPsc11JGmFQ14/+GDpX2UXR22ssPM9zWaK+Il6PLhT54GlO5TUOMM+awfWHYgBJ+j/cgwOK485pTVoTM9uzpWl4Qk8W7S1Hv81sqBW1qAXIm+Ttn5ak4c5dNPov1ClP9PqRPO+RVu6bWski2pumAD0PDD4E0MfY53Vq+0DJXKeWYKblDLrEYK7Y4QVTWuL0aV+MaNivFkfTDxaon/23/pRsP1oiOJ5ArJBiVwMSeDJBUkYtZjyOgVLoFKBaS5/SuZQMLrWEvOifuW2QTEMpIlTMHQotFRJRdnGH6wPRYemCl14LR5I/t7zERPKMR6aYC1AbFFjh2hTPTbdKioHul0+iMoYetEE9p5WT+weBMtxyYZtIXrnSpwF0DJ0OzEfGpB1iOckX+rkmVMU+PpZqFsb9ONqxe25sKWHCx7ViYapdqD8twXOAOmNBWojBdKqOkRQ31G/SqGkXUmfwCw1VkKvn9j2Xy6M6a3LwILV9NFzUzb4+z9xZOzuVzGBtxw8P83M2hM4SvAlCELfnsoLMJDAQxdFOHonTU4qHOXiOQxrFl9L7eqPEx3ykvcziRgemghUYvXIT1mGWwSryA1hz+46wrcGJwZv1wJFeb1PlyotIl4bhxEBr1XmErNI="
data/Gemfile CHANGED
@@ -1,6 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  group :test do
4
+ gem 'pry'
4
5
  gem 'rspec'
5
6
  gem 'webmock'
6
7
  end
data/README.md CHANGED
@@ -33,13 +33,16 @@ Client methods really just map 1 to 1 to API, see all of them beyond. Check API
33
33
  ```ruby
34
34
  agent(email)
35
35
  agents(options = {})
36
+ attachments(message_id)
36
37
  update_customer(options = {})
37
38
  customer(email)
38
39
  customers(options = {})
40
+ delete_webhook(id)
39
41
  folders(options = {})
40
42
  groups(options = {})
41
43
  mailboxes(options = {})
42
44
  create_message(options)
45
+ create_webhook(options)
43
46
  message(message_id)
44
47
  messages(ticket_number, options = {})
45
48
  tickets_count(options = {})
data/Rakefile CHANGED
@@ -1 +1,13 @@
1
1
  require "bundler/gem_tasks"
2
+
3
+ begin
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec) do |t|
7
+ t.rspec_opts = ["--tag=~integration"] unless ENV["TRAVIS_BRANCH"] == "master"
8
+ end
9
+
10
+ task :default => :spec
11
+ rescue LoadError
12
+ # no rspec available
13
+ end
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "groovehq"
5
+
6
+ require "pry"
7
+ Pry.start
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rake' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require "pathname"
10
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require "rubygems"
14
+ require "bundler/setup"
15
+
16
+ load Gem.bin_path("rake", "rake")
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -13,7 +13,8 @@ Gem::Specification.new do |spec|
13
13
  spec.license = "MIT"
14
14
 
15
15
  spec.files = `git ls-files -z`.split("\x0")
16
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
+ spec.bindir = "exe"
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
17
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
19
  spec.require_paths = ["lib"]
19
20
  spec.required_ruby_version = '>= 2.0'
@@ -3,7 +3,7 @@ module GrooveHQ
3
3
 
4
4
  module Messages
5
5
 
6
- def create_message(options)
6
+ def create_message(ticket_number, options)
7
7
  post("/tickets/#{ticket_number}/messages", options)
8
8
  end
9
9
 
@@ -39,8 +39,8 @@ module GrooveHQ
39
39
  put("/tickets/#{ticket_number}/priority", priority: priority)
40
40
  end
41
41
 
42
- def update_ticket_assigned_group(ticket_number, assigned_group)
43
- put("/tickets/#{ticket_number}/assigned_group", assigned_group: assigned_group)
42
+ def update_ticket_assigned_group(ticket_number, group)
43
+ put("/tickets/#{ticket_number}/assigned_group", group: group)
44
44
  end
45
45
 
46
46
  end
@@ -15,13 +15,13 @@ module GrooveHQ
15
15
 
16
16
  @data = OpenStruct.new(data.with_indifferent_access)
17
17
 
18
- @rels = parse_links(links).with_indifferent_access
18
+ @rels = parse_links(links)
19
19
  end
20
20
 
21
21
  def parse_links(links)
22
22
  (links || {}).each_with_object({}) do |(relation, value), result|
23
23
  result[relation] = Relation.new(@client, value[:href])
24
- end
24
+ end.with_indifferent_access
25
25
  end
26
26
 
27
27
  def method_missing(method_sym, *arguments, &block)
@@ -20,16 +20,16 @@ module GrooveHQ
20
20
  if meta_data.has_key?("pagination")
21
21
  links = {
22
22
  next: {
23
- "href" => meta_data["pagination"]["next_page"]
23
+ href: meta_data["pagination"]["next_page"]
24
24
  },
25
25
  prev: {
26
- "href" => meta_data["pagination"]["prev_page"]
26
+ href: meta_data["pagination"]["prev_page"]
27
27
  }
28
- }
28
+ }.with_indifferent_access
29
29
  end
30
30
 
31
31
  @data = OpenStruct.new(meta: meta_data, collection: collection)
32
- @rels = parse_links(links).with_indifferent_access
32
+ @rels = parse_links(links)
33
33
  end
34
34
 
35
35
  def each(&block)
@@ -1,3 +1,3 @@
1
1
  module GrooveHQ
2
- VERSION = "1.0.4"
2
+ VERSION = "1.0.5"
3
3
  end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe GrooveHQ::Client::Agents, integration: true do
4
+
5
+ let(:client) { GrooveHQ::Client.new }
6
+ let(:email) { "fodojyko@gmail.com" }
7
+
8
+ describe "#agent" do
9
+
10
+ let(:response) { client.agent(email) }
11
+
12
+ it "successfully gets agent" do
13
+ expect(response.data).to have_attributes(email: String)
14
+ end
15
+
16
+ it "gets the right agent info" do
17
+ expect(response.data).to have_attributes(email: email, first_name: "Testagent")
18
+ end
19
+
20
+ end
21
+
22
+ describe "#agents" do
23
+
24
+ let(:response) { client.agents }
25
+
26
+ it "successfully gets agents" do
27
+ expect(response).to be_instance_of GrooveHQ::ResourceCollection
28
+ end
29
+
30
+ it "gets the right agents info" do
31
+ expect(response.first.data).to have_attributes(email: email, first_name: "Testagent")
32
+ end
33
+
34
+ end
35
+
36
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe GrooveHQ::Client::Attachments, integration: true do
4
+
5
+ let(:client) { GrooveHQ::Client.new }
6
+
7
+ describe "#attachments" do
8
+
9
+ let(:response) { client.attachments(message_id) }
10
+
11
+ context "when message has attachments" do
12
+ let(:message_id) { '9789054751' } # message with attachments
13
+
14
+ it "successfully gets attachments" do
15
+ expect(response).to be_instance_of GrooveHQ::ResourceCollection
16
+ end
17
+ end
18
+
19
+ context "when message has no attachments" do
20
+ let(:message_id) { '25662182"' } # message without attachments
21
+
22
+ it "returns nil" do
23
+ expect(response).to be_nil
24
+ end
25
+ end
26
+
27
+ end
28
+
29
+ end
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ describe GrooveHQ::Client::Customers, integration: true do
4
+
5
+ let(:client) { GrooveHQ::Client.new }
6
+ let(:customer_email) { "customer@example.com" }
7
+
8
+ describe "#update_customer" do
9
+
10
+ it "updates customer info" do
11
+ customer = client.customer(customer_email)
12
+ new_about_text = "Some new about text"
13
+ response = client.update_customer(customer_email, about: new_about_text)
14
+ expect(customer.about).to eq new_about_text
15
+ expect(response.rels[:tickets].href).to eq "http://api.groovehq.com/v1/tickets?customer=#{customer.id}"
16
+ end
17
+
18
+ end
19
+
20
+ describe "#customer" do
21
+
22
+ let(:response) { client.customer(customer_email) }
23
+
24
+ it "successfully gets customer" do
25
+ expect(response.data).to have_attributes(id: String, email: String)
26
+ end
27
+
28
+ it "gets the right customer info" do
29
+ expect(response.data).to have_attributes(email: customer_email, name: "Testcustomer")
30
+ end
31
+
32
+ end
33
+
34
+ describe "#customers" do
35
+
36
+ let(:response) { client.customers }
37
+
38
+ it "successfully gets customers" do
39
+ expect(response).to be_instance_of GrooveHQ::ResourceCollection
40
+ end
41
+
42
+ it "gets the right customers info" do
43
+ expect(response.any? { |customer| customer.email == customer_email }).to be true
44
+ end
45
+
46
+ end
47
+
48
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe GrooveHQ::Client::Folders, integration: true do
4
+
5
+ let(:client) { GrooveHQ::Client.new }
6
+
7
+ describe "#folders" do
8
+
9
+ let(:response) { client.folders }
10
+
11
+ it "successfully gets folders" do
12
+ expect(response).to be_instance_of GrooveHQ::ResourceCollection
13
+ end
14
+
15
+ end
16
+
17
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe GrooveHQ::Client::Groups, integration: true do
4
+
5
+ let(:client) { GrooveHQ::Client.new }
6
+
7
+ describe "#groups" do
8
+
9
+ let(:response) { client.groups }
10
+
11
+ it "successfully gets groups" do
12
+ expect(response).to be_instance_of GrooveHQ::ResourceCollection
13
+ end
14
+
15
+ end
16
+
17
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe GrooveHQ::Client::Mailboxes, integration: true do
4
+
5
+ let(:client) { GrooveHQ::Client.new }
6
+
7
+ describe "#mailboxes" do
8
+
9
+ let(:response) { client.mailboxes }
10
+
11
+ it "successfully gets mailboxes" do
12
+ expect(response).to be_instance_of GrooveHQ::ResourceCollection
13
+ end
14
+
15
+ it "get the right mailboxes info" do
16
+ expect(response.first.name).to eq "Inbox"
17
+ end
18
+
19
+ end
20
+
21
+ end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+
3
+ describe GrooveHQ::Client::Messages, integration: true do
4
+
5
+ let(:client) { GrooveHQ::Client.new }
6
+
7
+ describe "#create_message" do
8
+
9
+ it "successfully creates message" do
10
+ body_text = "Some body text"
11
+ response = client.create_message('8', body: body_text)
12
+ expect(response.body).to eq body_text
13
+ end
14
+
15
+ end
16
+
17
+ describe "#message" do
18
+
19
+ let(:response) { client.message('25662284') }
20
+
21
+ it "successfully gets message" do
22
+ expect(response.data).to have_attributes(created_at: String)
23
+ end
24
+
25
+ it "gets the right message info" do
26
+ expect(response.body).to include("Hi Andrey,")
27
+ end
28
+
29
+ end
30
+
31
+ describe "#messages" do
32
+
33
+ let(:response) { client.messages('8') }
34
+
35
+ it "successfully gets messages" do
36
+ expect(response).to be_instance_of GrooveHQ::ResourceCollection
37
+ end
38
+
39
+ it "gets the right messages info" do
40
+ expect(response.first.body).to include("Whatsup")
41
+ end
42
+
43
+ end
44
+
45
+ end
@@ -0,0 +1,121 @@
1
+ require 'spec_helper'
2
+
3
+ describe GrooveHQ::Client::Tickets, integration: true do
4
+
5
+ let(:client) { GrooveHQ::Client.new }
6
+
7
+ describe "#tickets_count" do
8
+
9
+ it "successfully gets tickets count" do
10
+ response = client.tickets_count
11
+ expect(response).to be_instance_of GrooveHQ::Resource
12
+ end
13
+
14
+ end
15
+
16
+ describe "#create_ticket" do
17
+
18
+ it "successfully creates ticket" do
19
+ options = {
20
+ body: "Some body text",
21
+ from: "fodojyko@gmail.com",
22
+ to: "customer@example.com"
23
+ }
24
+ response = client.create_ticket(options)
25
+ expect(response.summary).to eq options[:body]
26
+ end
27
+
28
+ end
29
+
30
+ describe "#ticket" do
31
+
32
+ let(:response) { client.ticket('11') }
33
+
34
+ it "successfully gets ticket" do
35
+ expect(response.data).to have_attributes(created_at: String, number: Fixnum)
36
+ end
37
+
38
+ it "gets the right ticket info" do
39
+ expect(response.title).to eq "Hello"
40
+ end
41
+
42
+ end
43
+
44
+ describe "#tickets" do
45
+
46
+ it "successfully gets tickets" do
47
+ response = client.tickets
48
+ expect(response).to be_instance_of GrooveHQ::ResourceCollection
49
+ end
50
+
51
+ end
52
+
53
+ describe "#ticket_state" do
54
+
55
+ it "successfully gets ticket state" do
56
+ response = client.ticket_state('8')
57
+ expect(response).to be_instance_of String
58
+ end
59
+
60
+ end
61
+
62
+ describe "#update_ticket_state" do
63
+
64
+ it "successfully updates ticket state" do
65
+ client.update_ticket_state('8', 'pending')
66
+ client.update_ticket_state('8', 'opened')
67
+ current_state = client.ticket_state('8')
68
+ expect(current_state).to eq 'opened'
69
+ end
70
+
71
+ end
72
+
73
+ describe "#ticket_assignee" do
74
+
75
+ context "when ticket has an assignee" do
76
+ it "successfully gets ticket assignee" do
77
+ response = client.ticket_assignee('8')
78
+ expect(response.email).to eq "fodojyko@gmail.com"
79
+ end
80
+ end
81
+
82
+ context "when ticket has no assignee" do
83
+ it "returns nil" do
84
+ response = client.ticket_assignee('2')
85
+ expect(response).to be_nil
86
+ end
87
+ end
88
+
89
+ end
90
+
91
+ describe "#update_ticket_assignee" do
92
+
93
+ it "successfully updates ticket assignee" do
94
+ client.update_ticket_assignee('7', "fodojyko@gmail.com")
95
+ current_assignee = client.ticket_assignee('7')
96
+ expect(current_assignee.email).to eq "fodojyko@gmail.com"
97
+ end
98
+
99
+ end
100
+
101
+ describe "#update_ticket_priority" do
102
+
103
+ it "successfully updates ticket priority" do
104
+ client.update_ticket_priority('8', 'high')
105
+ current_priority = client.ticket('8').priority
106
+ expect(current_priority).to eq "high"
107
+ end
108
+
109
+ end
110
+
111
+ describe "#update_ticket_assigned_group" do
112
+
113
+ it "successfully updates ticket assigned group" do
114
+ client.update_ticket_assigned_group('8', 'test_group')
115
+ current_assigned_group = client.ticket('8').assigned_group
116
+ expect(current_assigned_group).to eq 'test_group'
117
+ end
118
+
119
+ end
120
+
121
+ end
@@ -34,9 +34,11 @@ describe GrooveHQ::Resource do
34
34
  next_page: "http://api.groovehq.dev/v1/tickets?page=2"
35
35
  }
36
36
  }
37
- }
37
+ }.stringify_keys
38
+
38
39
  resource = GrooveHQ::ResourceCollection.new(client, data)
39
40
  expect(resource.rels[:next]).to be_instance_of(GrooveHQ::Relation)
41
+ expect(resource.rels[:next].href).to eq("http://api.groovehq.dev/v1/tickets?page=2")
40
42
  end
41
43
 
42
44
  end
@@ -2,4 +2,9 @@ require 'webmock/rspec'
2
2
  require_relative '../lib/groovehq'
3
3
 
4
4
  RSpec.configure do |config|
5
+
6
+ config.before :all, integration: true do
7
+ WebMock.disable!
8
+ end
9
+
5
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: groovehq
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kirill Shirinkin
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2015-11-25 00:00:00.000000000 Z
11
+ date: 2016-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -79,6 +79,9 @@ files:
79
79
  - LICENSE.txt
80
80
  - README.md
81
81
  - Rakefile
82
+ - bin/console
83
+ - bin/rake
84
+ - bin/setup
82
85
  - groovehq.gemspec
83
86
  - lib/groovehq.rb
84
87
  - lib/groovehq/client.rb
@@ -97,6 +100,14 @@ files:
97
100
  - lib/groovehq/resource_collection.rb
98
101
  - lib/groovehq/version.rb
99
102
  - spec/groovehq/client/connection_spec.rb
103
+ - spec/groovehq/integration/agents_spec.rb
104
+ - spec/groovehq/integration/attachments_spec.rb
105
+ - spec/groovehq/integration/customers_spec.rb
106
+ - spec/groovehq/integration/folders_spec.rb
107
+ - spec/groovehq/integration/groups_spec.rb
108
+ - spec/groovehq/integration/mailboxes_spec.rb
109
+ - spec/groovehq/integration/messages_spec.rb
110
+ - spec/groovehq/integration/tickets_spec.rb
100
111
  - spec/groovehq/resource_collection_spec.rb
101
112
  - spec/groovehq/resource_spec.rb
102
113
  - spec/spec_helper.rb
@@ -126,6 +137,14 @@ specification_version: 4
126
137
  summary: Client library for GrooveHQ API.
127
138
  test_files:
128
139
  - spec/groovehq/client/connection_spec.rb
140
+ - spec/groovehq/integration/agents_spec.rb
141
+ - spec/groovehq/integration/attachments_spec.rb
142
+ - spec/groovehq/integration/customers_spec.rb
143
+ - spec/groovehq/integration/folders_spec.rb
144
+ - spec/groovehq/integration/groups_spec.rb
145
+ - spec/groovehq/integration/mailboxes_spec.rb
146
+ - spec/groovehq/integration/messages_spec.rb
147
+ - spec/groovehq/integration/tickets_spec.rb
129
148
  - spec/groovehq/resource_collection_spec.rb
130
149
  - spec/groovehq/resource_spec.rb
131
150
  - spec/spec_helper.rb