groovehq 1.0.6 → 1.0.7

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: 2145e0b487829c02c6e0080c1720c7667426e8fe
4
- data.tar.gz: 057464d5b2a57bc162728f8f4a65d8b29ba04ae4
3
+ metadata.gz: 6ed1b72ce7748263d1816950b4e54798a8a36ea6
4
+ data.tar.gz: 311110ca7f2c92ec912451f17854f93eecc7a80d
5
5
  SHA512:
6
- metadata.gz: f4a5e18231d02edeef700b2766135dc4f7737f933b5a20ff8832d79a10294b212e6e980c2a3bb923eaf45324e5f6025218e1c4c0d76e46cbb114fe95a14292e0
7
- data.tar.gz: 643eb4a6844f303f509a002ebb3a4545a7be9643697fb0823817deba82e03fb02ef9c96bb7dafeecac4e666c1174f28418b6bf2b576bd9640fd257ed77ff668a
6
+ metadata.gz: cc8bdd133b714ef069f3157adc02ef99b25d67f554d8171246aced2c7f5f84be5970f20fac25f133783e85b4d1b0610953ef6563cdbec5ed7932fef3774654e8
7
+ data.tar.gz: 4105163e0dbbacbc48d45473ff968ffa4b2569605f250fe429df824835b4f33f6f5c79e37064822950920286fe1384855b3440307279851e4c22b73f006207c9
@@ -2,6 +2,7 @@ language: ruby
2
2
  cache: bundler
3
3
  script: bundle exec rake spec
4
4
  rvm:
5
- - 2.1.4
5
+ - 2.3.1
6
+ - 2.4.1
6
7
  env:
7
8
  secure: "NiB0KwycVqFejW4SIK6bOlrFJMK00gUbPIQMWM59pmmM8NXjLrPsc11JGmFQ14/+GDpX2UXR22ssPM9zWaK+Il6PLhT54GlO5TUOMM+awfWHYgBJ+j/cgwOK485pTVoTM9uzpWl4Qk8W7S1Hv81sqBW1qAXIm+Ttn5ak4c5dNPov1ClP9PqRPO+RVu6bWski2pumAD0PDD4E0MfY53Vq+0DJXKeWYKblDLrEYK7Y4QVTWuL0aV+MaNivFkfTDxaon/23/pRsP1oiOJ5ArJBiVwMSeDJBUkYtZjyOgVLoFKBaS5/SuZQMLrWEvOifuW2QTEMpIlTMHQotFRJRdnGH6wPRYemCl14LR5I/t7zERPKMR6aYC1AbFFjh2hTPTbdKioHul0+iMoYetEE9p5WT+weBMtxyYZtIXrnSpwF0DJ0OzEfGpB1iOckX+rkmVMU+PpZqFsb9ONqxe25sKWHCx7ViYapdqD8twXOAOmNBWojBdKqOkRQ31G/SqGkXUmfwCw1VkKvn9j2Xy6M6a3LwILV9NFzUzb4+z9xZOzuVzGBtxw8P83M2hM4SvAlCELfnsoLMJDAQxdFOHonTU4qHOXiOQxrFl9L7eqPEx3ykvcziRgemghUYvXIT1mGWwSryA1hz+46wrcGJwZv1wJFeb1PlyotIl4bhxEBr1XmErNI="
@@ -23,7 +23,7 @@ module GrooveHQ
23
23
  private
24
24
 
25
25
  def request(http_method, path, options)
26
- response = self.class.send(http_method, path, { query: options })
26
+ response = self.class.send(http_method, path, { body: options })
27
27
  data = response.parsed_response
28
28
  parse_data(data)
29
29
  end
@@ -20,13 +20,15 @@ module GrooveHQ
20
20
  links = {}
21
21
 
22
22
  if meta_data.has_key?("pagination")
23
+ @total_pages = meta_data["pagination"]["total_pages"]
24
+ @current_page = meta_data["pagination"]["current_page"]
23
25
  links = {
24
26
  next: {
25
27
  href: meta_data["pagination"]["next_page"]
26
28
  },
27
29
  prev: {
28
30
  href: meta_data["pagination"]["prev_page"]
29
- }
31
+ },
30
32
  }
31
33
  end
32
34
 
@@ -40,6 +42,8 @@ module GrooveHQ
40
42
 
41
43
  collection.each { |item| yield item }
42
44
 
45
+ return self if @current_page == @total_pages
46
+
43
47
  rel = @rels[:next] or return self
44
48
  resource_collection = rel.get(@options.except(:page))
45
49
  resource_collection.each(&Proc.new)
@@ -1,3 +1,3 @@
1
1
  module GrooveHQ
2
- VERSION = "1.0.6"
2
+ VERSION = "1.0.7"
3
3
  end
@@ -8,11 +8,11 @@ describe GrooveHQ::Client::Customers, integration: true do
8
8
  describe "#update_customer" do
9
9
 
10
10
  it "updates customer info" do
11
- customer = client.customer(customer_email)
12
- new_about_text = "Some new about text"
11
+ new_about_text = "Some new about text " + SecureRandom.uuid
13
12
  response = client.update_customer(customer_email, about: new_about_text)
13
+ customer = client.customer(customer_email)
14
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}"
15
+ expect(response.rels[:tickets]).not_to be_nil
16
16
  end
17
17
 
18
18
  end
@@ -16,7 +16,7 @@ describe GrooveHQ::Client::Messages, integration: true do
16
16
 
17
17
  describe "#message" do
18
18
 
19
- let(:response) { client.message('25662284') }
19
+ let(:response) { client.message('5850909715') }
20
20
 
21
21
  it "successfully gets message" do
22
22
  expect(response.data).to have_attributes(created_at: String)
@@ -25,6 +25,25 @@ describe GrooveHQ::Client::Tickets, integration: true do
25
25
  expect(response.summary).to eq options[:body]
26
26
  end
27
27
 
28
+ it "successfully can include customer details in ticket" do
29
+ customer_hash = {
30
+ email: "customer@example.com",
31
+ about: "Your internal reference",
32
+ company_name: "SomeCompany Pty Ltd"
33
+ }
34
+
35
+ options = {
36
+ body: "Some body text",
37
+ from: "fodojyko@gmail.com",
38
+ to: customer_hash
39
+ }
40
+ response = client.create_ticket(options)
41
+ customer = response.rels['customer'].get
42
+ expect(customer.company_name).to eq customer_hash[:company_name]
43
+ expect(customer.email).to eq customer_hash[:email]
44
+ expect(customer.about).to eq customer_hash[:about]
45
+ end
46
+
28
47
  end
29
48
 
30
49
  describe "#ticket" do
@@ -63,7 +63,10 @@ describe GrooveHQ::Resource do
63
63
  tickets: [{ title: "Ticket 1" }],
64
64
  meta: {
65
65
  pagination: {
66
- next_page: "http://api.groovehq.dev/v1/tickets?page=2"
66
+ next_page: "http://api.groovehq.dev/v1/tickets?page=2",
67
+ current_page: 1,
68
+ total_pages: 3,
69
+ total_count: 3
67
70
  }
68
71
  }
69
72
  }.stringify_keys
@@ -73,7 +76,10 @@ describe GrooveHQ::Resource do
73
76
  meta: {
74
77
  pagination: {
75
78
  prev_page: "http://api.groovehq.dev/v1/tickets?page=1",
76
- next_page: "http://api.groovehq.dev/v1/tickets?page=3"
79
+ next_page: "http://api.groovehq.dev/v1/tickets?page=3",
80
+ current_page: 2,
81
+ total_pages: 3,
82
+ total_count: 3
77
83
  }
78
84
  }
79
85
  }.stringify_keys
@@ -82,11 +88,19 @@ describe GrooveHQ::Resource do
82
88
  tickets: [{ title: "Ticket 3"}],
83
89
  meta: {
84
90
  pagination: {
91
+ next_page: "http://api.groovehq.dev/v1/tickets",
85
92
  prev_page: "http://api.groovehq.dev/v1/tickets?page=2",
93
+ current_page: 3,
94
+ total_pages: 3,
95
+ total_count: 3
86
96
  }
87
97
  }
88
98
  }.stringify_keys
89
99
 
100
+ stub_request(:get, "http://api.groovehq.dev/v1/tickets").
101
+ with(headers: {'Authorization' => 'Bearer phantogram'}).
102
+ to_return(body: page_1.to_json, status: 200)
103
+
90
104
  stub_request(:get, "http://api.groovehq.dev/v1/tickets?page=2").
91
105
  with(headers: {'Authorization' => 'Bearer phantogram'}).
92
106
  to_return(body: page_2.to_json, status: 200)
@@ -115,7 +129,7 @@ describe GrooveHQ::Resource do
115
129
 
116
130
  it "respects :per_page and other parameters except :page" do
117
131
  resource = GrooveHQ::ResourceCollection.new(client, @page_1, page: 1, per_page: 20, foo: "bar")
118
- stub_request(:get, "http://api.groovehq.dev/v1/tickets?page=2&per_page=20&foo=bar").
132
+ stub_request(:get, /http:\/\/api.groovehq.dev\/v1\/tickets\?page=\d+(&per_page=\d+)?(&foo=bar)?/).
119
133
  with(headers: {'Authorization' => 'Bearer phantogram'}).
120
134
  to_return(body: {tickets: []}.to_json, status: 200)
121
135
 
@@ -2,9 +2,11 @@ require 'webmock/rspec'
2
2
  require_relative '../lib/groovehq'
3
3
 
4
4
  RSpec.configure do |config|
5
+ config.before :all do
6
+ WebMock.enable!
7
+ end
5
8
 
6
9
  config.before :all, integration: true do
7
10
  WebMock.disable!
8
11
  end
9
-
10
12
  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.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kirill Shirinkin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-02-28 00:00:00.000000000 Z
11
+ date: 2017-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -131,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
131
  version: '0'
132
132
  requirements: []
133
133
  rubyforge_project:
134
- rubygems_version: 2.4.8
134
+ rubygems_version: 2.6.8
135
135
  signing_key:
136
136
  specification_version: 4
137
137
  summary: Client library for GrooveHQ API.