groovehq 1.0.0
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 +7 -0
- data/.gitignore +14 -0
- data/.travis.yml +5 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +22 -0
- data/README.md +3 -0
- data/Rakefile +1 -0
- data/groovehq.gemspec +26 -0
- data/lib/groovehq.rb +11 -0
- data/lib/groovehq/client.rb +34 -0
- data/lib/groovehq/client/agents.rb +17 -0
- data/lib/groovehq/client/connection.rb +52 -0
- data/lib/groovehq/client/customers.rb +21 -0
- data/lib/groovehq/client/folders.rb +14 -0
- data/lib/groovehq/client/groups.rb +13 -0
- data/lib/groovehq/client/mailboxes.rb +13 -0
- data/lib/groovehq/client/messages.rb +21 -0
- data/lib/groovehq/client/tickets.rb +50 -0
- data/lib/groovehq/client/webhooks.rb +17 -0
- data/lib/groovehq/relation.rb +11 -0
- data/lib/groovehq/resource.rb +37 -0
- data/lib/groovehq/resource_collection.rb +39 -0
- data/lib/groovehq/version.rb +3 -0
- data/spec/groovehq/client/connection_spec.rb +110 -0
- data/spec/groovehq/resource_collection_spec.rb +44 -0
- data/spec/groovehq/resource_spec.rb +55 -0
- data/spec/spec_helper.rb +5 -0
- metadata +131 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5297d2c40416cd886269a0843c1fb532d23c25c6
|
4
|
+
data.tar.gz: bec7bed50a2eb6e43dd9186de38757bee6a23dce
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 951ce20a379d848d1cfffbfd32d1585e7ee4d74f9693de5b04b3389f411c35ccf37c37af71822805c0a52a48034344ea4e55a7ec0d47c328ccfce6e67e89206a
|
7
|
+
data.tar.gz: c0aea7da762427a4f8851e7a2904f03ba8c38a4087b7972574ac9eee1f6e06a81d6ddb357e63d1a9e2231c82bdf8a0d1eeeae135e6faf07efbaaeffbae653772
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Kirill Shirinkin
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/groovehq.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'groovehq/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "groovehq"
|
8
|
+
spec.version = GrooveHQ::VERSION
|
9
|
+
spec.authors = ["Kirill Shirinkin"]
|
10
|
+
spec.email = ["fodojyko@gmail.com"]
|
11
|
+
spec.summary = %q{Client library for GrooveHQ API.}
|
12
|
+
spec.description = %q{Client library for GrooveHQ API.}
|
13
|
+
spec.homepage = "https://github.com/Fodoj/groovehq"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "httparty"
|
22
|
+
spec.add_dependency "activesupport"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
end
|
data/lib/groovehq.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require "active_support/core_ext/hash"
|
2
|
+
require "httparty"
|
3
|
+
require "groovehq/version"
|
4
|
+
require "groovehq/relation"
|
5
|
+
require "groovehq/resource"
|
6
|
+
require "groovehq/resource_collection"
|
7
|
+
require "groovehq/client"
|
8
|
+
|
9
|
+
module GrooveHQ
|
10
|
+
# Your code goes here...
|
11
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "groovehq/client/connection"
|
2
|
+
|
3
|
+
require "groovehq/client/agents"
|
4
|
+
require "groovehq/client/customers"
|
5
|
+
require "groovehq/client/folders"
|
6
|
+
require "groovehq/client/groups"
|
7
|
+
require "groovehq/client/mailboxes"
|
8
|
+
require "groovehq/client/messages"
|
9
|
+
require "groovehq/client/tickets"
|
10
|
+
require "groovehq/client/webhooks"
|
11
|
+
|
12
|
+
module GrooveHQ
|
13
|
+
class Client
|
14
|
+
include HTTParty
|
15
|
+
include GrooveHQ::Client::Connection
|
16
|
+
include GrooveHQ::Client::Agents
|
17
|
+
include GrooveHQ::Client::Customers
|
18
|
+
include GrooveHQ::Client::Folders
|
19
|
+
include GrooveHQ::Client::Groups
|
20
|
+
include GrooveHQ::Client::Mailboxes
|
21
|
+
include GrooveHQ::Client::Messages
|
22
|
+
include GrooveHQ::Client::Tickets
|
23
|
+
include GrooveHQ::Client::Webhooks
|
24
|
+
|
25
|
+
base_uri "https://api.groovehq.com/v1"
|
26
|
+
format :json
|
27
|
+
|
28
|
+
def initialize(access_token = nil)
|
29
|
+
access_token ||= ENV["GROOVEHQ_ACCESS_TOKEN"]
|
30
|
+
self.class.default_options.merge!(headers: { 'Authorization' => "Bearer #{access_token}" })
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module GrooveHQ
|
2
|
+
|
3
|
+
class Client
|
4
|
+
|
5
|
+
module Connection
|
6
|
+
|
7
|
+
def get(path, options = {})
|
8
|
+
request :get, path, options
|
9
|
+
end
|
10
|
+
|
11
|
+
def post(path, options = {})
|
12
|
+
request :post, path, options
|
13
|
+
end
|
14
|
+
|
15
|
+
def put(path, options = {})
|
16
|
+
request :put, path, options
|
17
|
+
end
|
18
|
+
|
19
|
+
def delete(path, options = {})
|
20
|
+
request :delete, path, options
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def request(http_method, path, options)
|
26
|
+
response = self.class.send(http_method, path, { query: options })
|
27
|
+
data = response.parsed_response
|
28
|
+
parse_data(data)
|
29
|
+
end
|
30
|
+
|
31
|
+
def parse_data(original_data)
|
32
|
+
return unless original_data
|
33
|
+
|
34
|
+
# This hack is added primaraly to deal with API response inconsistencies:
|
35
|
+
# https://www.groovehq.com/docs/ticket-counts#listing-ticket-counts (one key per folder)
|
36
|
+
# https://www.groovehq.com/docs/tickets#listing-tickets (has two keys: 'tickets' and 'meta')
|
37
|
+
# https://www.groovehq.com/docs/tickets#finding-one-ticket (one key: 'ticket')
|
38
|
+
# :(
|
39
|
+
data = original_data.keys.count <= 2 ? original_data.values.first : original_data
|
40
|
+
|
41
|
+
case data
|
42
|
+
when Hash then Resource.new(self, data)
|
43
|
+
when Array then ResourceCollection.new(self, original_data)
|
44
|
+
when nil then nil
|
45
|
+
else data
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module GrooveHQ
|
2
|
+
class Client
|
3
|
+
|
4
|
+
module Customers
|
5
|
+
|
6
|
+
def update_customer(options)
|
7
|
+
post("/tickets/#{ticket_number}/messages", options)
|
8
|
+
end
|
9
|
+
|
10
|
+
def customer(email)
|
11
|
+
get("/customers/#{email}")
|
12
|
+
end
|
13
|
+
|
14
|
+
def customers(options = {})
|
15
|
+
get("/customers", options)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module GrooveHQ
|
2
|
+
class Client
|
3
|
+
|
4
|
+
module Messages
|
5
|
+
|
6
|
+
def create_message(options)
|
7
|
+
post("/tickets/#{ticket_number}/messages", options)
|
8
|
+
end
|
9
|
+
|
10
|
+
def message(message_id)
|
11
|
+
get("/messages/#{message_id}")
|
12
|
+
end
|
13
|
+
|
14
|
+
def messages(ticket_number, options = {})
|
15
|
+
get("/tickets/#{ticket_number}/messages", options)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module GrooveHQ
|
2
|
+
class Client
|
3
|
+
|
4
|
+
module Tickets
|
5
|
+
|
6
|
+
# FIXME Doesn't work yet, shows only one random folder at the moment
|
7
|
+
def tickets_count(options = {})
|
8
|
+
get("/tickets/count", options)
|
9
|
+
end
|
10
|
+
|
11
|
+
def create_ticket(options)
|
12
|
+
post("/tickets", options)
|
13
|
+
end
|
14
|
+
|
15
|
+
def ticket(ticket_number)
|
16
|
+
get("/tickets/#{ticket_number}")
|
17
|
+
end
|
18
|
+
|
19
|
+
def tickets(options = {})
|
20
|
+
get("/tickets", options)
|
21
|
+
end
|
22
|
+
|
23
|
+
def ticket_state(ticket_number)
|
24
|
+
get("/tickets/#{ticket_number}/state")
|
25
|
+
end
|
26
|
+
|
27
|
+
def update_ticket_state(ticket_number, state)
|
28
|
+
put("/tickets/#{ticket_number}/state", state: state)
|
29
|
+
end
|
30
|
+
|
31
|
+
def ticket_assignee(ticket_number)
|
32
|
+
get("/tickets/#{ticket_number}/assignee")
|
33
|
+
end
|
34
|
+
|
35
|
+
def update_ticket_assignee(ticket_number, assignee)
|
36
|
+
put("/tickets/#{ticket_number}/assignee", assignee: assignee)
|
37
|
+
end
|
38
|
+
|
39
|
+
def update_ticket_priority(ticket_number, priority)
|
40
|
+
put("/tickets/#{ticket_number}/assignee", priority: priority)
|
41
|
+
end
|
42
|
+
|
43
|
+
def update_ticket_assigned_group(ticket_number, assigned_group)
|
44
|
+
put("/tickets/#{ticket_number}/assigned_group", assigned_group: assigned_group)
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module GrooveHQ
|
2
|
+
|
3
|
+
class Resource
|
4
|
+
attr_reader :rels, :data
|
5
|
+
|
6
|
+
def initialize(client, data)
|
7
|
+
data = {} unless data.is_a?(Hash)
|
8
|
+
|
9
|
+
@client = client
|
10
|
+
|
11
|
+
data = data.with_indifferent_access
|
12
|
+
|
13
|
+
links = data.delete(:links) { Hash.new }
|
14
|
+
links[:self] = data.delete(:href) if data.has_key?(:href)
|
15
|
+
|
16
|
+
@data = OpenStruct.new(data.with_indifferent_access)
|
17
|
+
|
18
|
+
@rels = parse_links(links).with_indifferent_access
|
19
|
+
end
|
20
|
+
|
21
|
+
def parse_links(links)
|
22
|
+
(links || {}).each_with_object({}) do |(relation, value), result|
|
23
|
+
result[relation] = Relation.new(@client, value["href"])
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def method_missing(method_sym, *arguments, &block)
|
28
|
+
if @data.respond_to?(method_sym)
|
29
|
+
@data.send(method_sym)
|
30
|
+
else
|
31
|
+
super
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module GrooveHQ
|
2
|
+
|
3
|
+
class ResourceCollection < Resource
|
4
|
+
include Enumerable
|
5
|
+
|
6
|
+
def initialize(client, data)
|
7
|
+
data = {} unless data.is_a?(Hash)
|
8
|
+
data = data.with_indifferent_access
|
9
|
+
|
10
|
+
meta_data = data.delete(:meta) { Hash.new }
|
11
|
+
|
12
|
+
collection = Array(data.values.first).map do |item|
|
13
|
+
Resource.new(client, item)
|
14
|
+
end
|
15
|
+
|
16
|
+
links = {}
|
17
|
+
|
18
|
+
if meta_data.has_key?("pagination")
|
19
|
+
links = {
|
20
|
+
next: {
|
21
|
+
href: meta_data["pagination"]["next_page"]
|
22
|
+
},
|
23
|
+
prev: {
|
24
|
+
href: meta_data["pagination"]["prev_page"]
|
25
|
+
}
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
@data = OpenStruct.new(meta: meta_data, collection: collection)
|
30
|
+
@rels = parse_links(links).with_indifferent_access
|
31
|
+
end
|
32
|
+
|
33
|
+
def each(&block)
|
34
|
+
collection.each { |item| yield item }
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GrooveHQ::Client::Connection do
|
4
|
+
|
5
|
+
let(:client) { GrooveHQ::Client.new("phantogram") }
|
6
|
+
|
7
|
+
it "returns nil for empty response" do
|
8
|
+
stub_request(:get, "https://api.groovehq.com/v1/tickets").to_return(body: "")
|
9
|
+
expect(client.get("/tickets")).to eql(nil)
|
10
|
+
end
|
11
|
+
|
12
|
+
context "nested hash as response with single root key" do
|
13
|
+
|
14
|
+
let(:response) do
|
15
|
+
{
|
16
|
+
ticket: {
|
17
|
+
number: 1,
|
18
|
+
summary: "This is the first 100 characters of the first message...",
|
19
|
+
links: {
|
20
|
+
assignee: {
|
21
|
+
href: "https://api.groovehq.com/v1/agents/matt@groovehq.com"
|
22
|
+
}
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}.to_json
|
26
|
+
end
|
27
|
+
|
28
|
+
before(:each) do
|
29
|
+
stub_request(:get, "https://api.groovehq.com/v1/tickets/1").to_return(body: response)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "returns resource for single root key" do
|
33
|
+
expect(client.get("/tickets/1")).to be_instance_of(GrooveHQ::Resource)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "returns resource with correct relations" do
|
37
|
+
expect(client.get("/tickets/1").rels[:assignee].href).to eql("https://api.groovehq.com/v1/agents/matt@groovehq.com")
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
context "single key-value pair in response" do
|
43
|
+
|
44
|
+
let(:response) do
|
45
|
+
{ state: "open" }.to_json
|
46
|
+
end
|
47
|
+
|
48
|
+
before(:each) do
|
49
|
+
stub_request(:get, "https://api.groovehq.com/v1/tickets/1/state").to_return(body: response)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "returns response as it is" do
|
53
|
+
expect(client.get("/tickets/1/state")).to eql "open"
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
context "multiple root key-value pairs in response" do
|
59
|
+
|
60
|
+
let(:response) do
|
61
|
+
{
|
62
|
+
"728525" => 1,
|
63
|
+
"987452" => 0,
|
64
|
+
"842376" => 0
|
65
|
+
}.to_json
|
66
|
+
end
|
67
|
+
|
68
|
+
before(:each) do
|
69
|
+
stub_request(:get, "https://api.groovehq.com/v1/tickets/count").to_return(body: response)
|
70
|
+
end
|
71
|
+
|
72
|
+
it "returns response as it is" do
|
73
|
+
expect(client.get("/tickets/count").data.to_h.keys.count).to eql 3
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
context "array of hashes in response" do
|
79
|
+
|
80
|
+
let(:response) do
|
81
|
+
{
|
82
|
+
tickets: [
|
83
|
+
{ number: 1 },
|
84
|
+
{ number: 2 },
|
85
|
+
{ number: 3 }
|
86
|
+
],
|
87
|
+
meta: {
|
88
|
+
pagination: {
|
89
|
+
next_page: "https://api.groovehq.com/v1/tickets/?page=2",
|
90
|
+
prev_page: nil
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}.to_json
|
94
|
+
end
|
95
|
+
|
96
|
+
before(:each) do
|
97
|
+
stub_request(:get, "https://api.groovehq.com/v1/tickets").to_return(body: response)
|
98
|
+
end
|
99
|
+
|
100
|
+
it "builds array of resources from response" do
|
101
|
+
expect(client.get("/tickets").data[:collection].count).to eql 3
|
102
|
+
end
|
103
|
+
|
104
|
+
it "returns relations for pagination" do
|
105
|
+
expect(client.get("/tickets").rels[:next]).to be_instance_of(GrooveHQ::Relation)
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GrooveHQ::Resource do
|
4
|
+
|
5
|
+
let(:client) { GrooveHQ::Client.new("phantogram") }
|
6
|
+
|
7
|
+
context "#data" do
|
8
|
+
|
9
|
+
it "returns empty data for invalid input" do
|
10
|
+
resource = GrooveHQ::ResourceCollection.new(self, "")
|
11
|
+
expect(resource.count).to eql(0)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "parses data correctly" do
|
15
|
+
data = {
|
16
|
+
tickets: [ { name: "When I am small" } ]
|
17
|
+
}
|
18
|
+
resource = GrooveHQ::ResourceCollection.new(self, data)
|
19
|
+
expect(resource.first.name).to eql "When I am small"
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
context "#rels" do
|
25
|
+
|
26
|
+
it "parses relations correctly" do
|
27
|
+
data = {
|
28
|
+
tickets: [],
|
29
|
+
meta: {
|
30
|
+
pagination: {
|
31
|
+
current_page: 1,
|
32
|
+
total_pages: 23,
|
33
|
+
total_count: 23,
|
34
|
+
next_page: "http://api.groovehq.dev/v1/tickets?page=2"
|
35
|
+
}
|
36
|
+
}
|
37
|
+
}
|
38
|
+
resource = GrooveHQ::ResourceCollection.new(self, data)
|
39
|
+
expect(resource.rels[:next]).to be_instance_of(GrooveHQ::Relation)
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GrooveHQ::Resource do
|
4
|
+
|
5
|
+
let(:client) { GrooveHQ::Client.new("phantogram") }
|
6
|
+
|
7
|
+
context "#data" do
|
8
|
+
|
9
|
+
it "returns empty data for invalid input" do
|
10
|
+
resource = GrooveHQ::Resource.new(self, "")
|
11
|
+
expect(resource.data.to_h).to eql({})
|
12
|
+
end
|
13
|
+
|
14
|
+
it "parses data correctly" do
|
15
|
+
data = {
|
16
|
+
name: "When I am small"
|
17
|
+
}
|
18
|
+
resource = GrooveHQ::Resource.new(self, data)
|
19
|
+
expect(resource.data[:name]).to eql "When I am small"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "adds getters for data" do
|
23
|
+
data = {
|
24
|
+
name: "When I am small"
|
25
|
+
}
|
26
|
+
resource = GrooveHQ::Resource.new(self, data)
|
27
|
+
expect(resource.name).to eql "When I am small"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context "#rels" do
|
32
|
+
|
33
|
+
it "parses relations correctly" do
|
34
|
+
data = {
|
35
|
+
links: {
|
36
|
+
assignee: {
|
37
|
+
href: "https://api.groovehq.com/v1/agents/matt@groovehq.com"
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
41
|
+
resource = GrooveHQ::Resource.new(self, data)
|
42
|
+
expect(resource.rels[:assignee]).to be_instance_of(GrooveHQ::Relation)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "parses self relation correctly" do
|
46
|
+
data = {
|
47
|
+
href: "https://api.groovehq.com/v1/agents/matt@groovehq.com"
|
48
|
+
}
|
49
|
+
resource = GrooveHQ::Resource.new(self, data)
|
50
|
+
expect(resource.rels[:self]).to be_instance_of(GrooveHQ::Relation)
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: groovehq
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kirill Shirinkin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activesupport
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.7'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.7'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
description: Client library for GrooveHQ API.
|
70
|
+
email:
|
71
|
+
- fodojyko@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".travis.yml"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- groovehq.gemspec
|
83
|
+
- lib/groovehq.rb
|
84
|
+
- lib/groovehq/client.rb
|
85
|
+
- lib/groovehq/client/agents.rb
|
86
|
+
- lib/groovehq/client/connection.rb
|
87
|
+
- lib/groovehq/client/customers.rb
|
88
|
+
- lib/groovehq/client/folders.rb
|
89
|
+
- lib/groovehq/client/groups.rb
|
90
|
+
- lib/groovehq/client/mailboxes.rb
|
91
|
+
- lib/groovehq/client/messages.rb
|
92
|
+
- lib/groovehq/client/tickets.rb
|
93
|
+
- lib/groovehq/client/webhooks.rb
|
94
|
+
- lib/groovehq/relation.rb
|
95
|
+
- lib/groovehq/resource.rb
|
96
|
+
- lib/groovehq/resource_collection.rb
|
97
|
+
- lib/groovehq/version.rb
|
98
|
+
- spec/groovehq/client/connection_spec.rb
|
99
|
+
- spec/groovehq/resource_collection_spec.rb
|
100
|
+
- spec/groovehq/resource_spec.rb
|
101
|
+
- spec/spec_helper.rb
|
102
|
+
homepage: https://github.com/Fodoj/groovehq
|
103
|
+
licenses:
|
104
|
+
- MIT
|
105
|
+
metadata: {}
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
requirements: []
|
121
|
+
rubyforge_project:
|
122
|
+
rubygems_version: 2.2.2
|
123
|
+
signing_key:
|
124
|
+
specification_version: 4
|
125
|
+
summary: Client library for GrooveHQ API.
|
126
|
+
test_files:
|
127
|
+
- spec/groovehq/client/connection_spec.rb
|
128
|
+
- spec/groovehq/resource_collection_spec.rb
|
129
|
+
- spec/groovehq/resource_spec.rb
|
130
|
+
- spec/spec_helper.rb
|
131
|
+
has_rdoc:
|