flowdock 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: add821dc4a38cf06e2c3f714696a492b4d33c662
4
- data.tar.gz: f7e1b06102bacda9ce5ae06d07e89780fca71091
3
+ metadata.gz: 2e8c2164455898ff017ff0cbe2a0fe9c0615de15
4
+ data.tar.gz: 67af9f77904b26d42864b709d1a8ed112bc4009c
5
5
  SHA512:
6
- metadata.gz: c297de7187f02165ae0f3293b749b71e3950c4c3c7f51c0826c1508e864962e9fc46e368590f83d277c73ec8cef886bf0116b423474949a7369fad8ebffabf77
7
- data.tar.gz: fa3bf91e94f7ae7f8367f18c9dee67e966e27d95548ed9670f51126ff2b13b6af299899b031154f8bb56b7808c688e9749ece4402436311222bbdde4487c3bb1
6
+ metadata.gz: 20cf692d3e6f09405972d71b9888fd60c3eac5e27978a63c545f4e9d2ac782e390a33cf8773be14d5592d498f079557b92d195178c8d078711cf56c3469723a7
7
+ data.tar.gz: fea63857c0f2130a68f79f634a9c17feba1b46022efe437adb383499d14136aad8cb421d5e2c71ca103f0e83b2a7a9b9b59606b16f9d8a89dc183be1ebc47681
@@ -1,3 +1,5 @@
1
1
  rvm:
2
- - 1.9.3
2
+ - 2.0
3
+ - 2.1
4
+ - 2.2
3
5
  - jruby
data/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # Flowdock
2
2
 
3
- Ruby Gem for using the Flowdock Push API. See [Push API documentation](http://www.flowdock.com/api/push) for details.
3
+ Ruby gem for using the Flowdock Push API. See the [Push API documentation](http://www.flowdock.com/api/push) for details.
4
4
 
5
5
  ## Build Status
6
6
 
7
7
  [![Build Status](https://secure.travis-ci.org/flowdock/flowdock-api.png)](http://travis-ci.org/flowdock/flowdock-api)
8
8
 
9
- flowdock gem is tested on Ruby 1.9.3 and JRuby.
9
+ The Flowdock gem is tested on Ruby 2.1 and JRuby.
10
10
 
11
11
  ## Dependencies
12
12
 
@@ -17,47 +17,78 @@ flowdock gem is tested on Ruby 1.9.3 and JRuby.
17
17
 
18
18
  gem install flowdock
19
19
 
20
- If you're using JRuby, you'll also need to install jruby-openssl gem.
20
+ If you're using JRuby, you'll also need to install the `jruby-openssl` gem.
21
21
 
22
22
  ## Usage
23
23
 
24
- To post content to Chat or Team Inbox using `Flowdock::Flow`, you need to use the target flow's API token.
24
+ To post content to a flow's chat or team inbox using `Flowdock::Flow`, you need to use the target flow's API token or a source's flow_token.
25
25
 
26
- Alternatively you can use your personal api token and the `Flowdock::Client`.
26
+ Alternatively, you can use your personal API token and the `Flowdock::Client`.
27
27
 
28
- All tokens can be found in [tokens page](https://www.flowdock.com/account/tokens).
28
+ Personal and flow's tokens can be found on the [tokens page](https://www.flowdock.com/account/tokens).
29
29
 
30
30
  ### REST API
31
31
 
32
- To create an api client you need your personal api token:
32
+ To create an API client, you need your personal [API token](https://flowdock.com/account/tokens), an [OAuth token](https://www.flowdock.com/api/authentication) or a [source's flow_token](https://www.flowdock.com/api/sources).
33
+
34
+ Note that a `flow_token` will only allow you to post [thread messages](https://www.flowdock.com/api/production-integrations#/post-inbox) to the flow that the source belongs to.
33
35
 
34
36
  ```ruby
35
37
  require 'rubygems'
36
38
  require 'flowdock'
37
39
 
38
- # Create a client that uses you api token to authenticate
39
- client = Flowdock::Client.new(api_token: '__MY_PERSONAL_API_TOKEN__')
40
+ # Create a client that uses your personal API token to authenticate
41
+ api_token_client = Flowdock::Client.new(api_token: '__MY_PERSONAL_API_TOKEN__')
42
+
43
+ # Create a client that uses a source's flow_token to authenticate. Can only use post_to_thread
44
+ flow_token_client = Flowdock::Client.new(flow_token: '__FLOW_TOKEN__')
40
45
  ```
41
46
 
42
47
  #### Posting to Chat
43
48
 
44
- To send a chat message or comment, you can use the client.chat_message:
49
+ To send a chat message or comment, you can use `client.chat_message`:
45
50
 
46
51
  ```ruby
47
52
  flow_id = 'acdcabbacd0123456789'
48
53
 
49
54
  # Send a simple chat message
50
- client.chat_message(flow: flow_id, content: "I'm sending a message!", tags: ['foo', 'bar'])
55
+ api_token_client.chat_message(flow: flow_id, content: "I'm sending a message!", tags: ['foo', 'bar'])
51
56
 
52
57
  # Send a comment to message 1234
53
- client.chat_message(flow: flow_id, content: "Now I'm commenting!", message: 1234)
58
+ api_token_client.chat_message(flow: flow_id, content: "Now I'm commenting!", message: 1234)
54
59
  ```
55
60
 
56
61
  Both methods return the created message as a hash.
57
62
 
58
- #### Arbitary api access
63
+ #### Post a threaded messages
64
+
65
+ You can post `activity` and `discussion` events to a [threaded conversation](https://www.flowdock.com/api/integration-getting-started) in Flowdock.
66
+
67
+ ```
68
+ flow_token_client.post_to_thread(
69
+ event: "activity",
70
+ author: {
71
+ name: "anttipitkanen",
72
+ avatar: "https://avatars.githubusercontent.com/u/946511?v=2",
73
+ },
74
+ title: "activity title",
75
+ external_thread_id: "your-id-here",
76
+ thread: {
77
+ title: "this is required if you provide a thread field at all",
78
+ body: "<p>some html content</p>",
79
+ external_url: "https://example.com/issue/123",
80
+ status: {
81
+ color: "green",
82
+ value: "open"
83
+ }
84
+ }
85
+ }
86
+ ```
59
87
 
60
- You can use the client to access api in other ways too. See [REST API documentation](http://www.flowdock.com/api/rest) for all the resources.
88
+
89
+ #### Arbitary API access
90
+
91
+ You can use the client to access the Flowdock API in other ways, too. See the [REST API documentation](http://www.flowdock.com/api/rest) for all the resources.
61
92
 
62
93
  ```ruby
63
94
 
@@ -75,32 +106,34 @@ client.post('/flows/acme/my_flow/invitations', email: 'user@example.com', messag
75
106
 
76
107
  ```
77
108
 
78
- ### Push api
109
+ ### Push API
79
110
 
80
- To use the push api, you need a flow token:
111
+ **Note:** the Push API is in the process of being deprecated. [Creating a source](https://www.flowdock.com/api/integration-getting-started) along with a flow_token is recommended instead.
81
112
 
82
- #### Posting to Chat
113
+ To use the Push API, you need the flow's API token:
114
+
115
+ #### Posting to the chat
83
116
 
84
117
  ```ruby
85
118
  require 'rubygems'
86
119
  require 'flowdock'
87
120
 
88
- # create a new Flow object with target flow's api token and external user name (enough for posting to Chat)
89
- flow = Flowdock::Flow.new(:api_token => "__FLOW_TOKEN__", :external_user_name => "John")
121
+ # create a new Flow object with target flow's API token and external user name (enough for posting to the chat)
122
+ flow = Flowdock::Flow.new(:api_token => "__FLOW_API_TOKEN__", :external_user_name => "John")
90
123
 
91
124
  # send message to Chat
92
125
  flow.push_to_chat(:content => "Hello!", :tags => ["cool", "stuff"])
93
126
  ```
94
127
 
95
- #### Posting to Team Inbox
128
+ #### Posting to the team inbox
96
129
 
97
130
  ```ruby
98
- # create a new Flow object with target flow's api token and sender information for Team Inbox posting
99
- flow = Flowdock::Flow.new(:api_token => "__FLOW_TOKEN__",
131
+ # create a new Flow object with the target flow's API token and sender information
132
+ flow = Flowdock::Flow.new(:api_token => "__FLOW_API_TOKEN__",
100
133
  :source => "myapp", :from => {:name => "John Doe", :address => "john.doe@example.com"})
101
134
 
102
135
  # send message to Team Inbox
103
- flow.push_to_team_inbox(:subject => "Greetings from Flowdock API Gem!",
136
+ flow.push_to_team_inbox(:subject => "Greetings from the Flowdock API gem!",
104
137
  :content => "<h2>It works!</h2><p>Now you can start developing your awesome application for Flowdock.</p>",
105
138
  :tags => ["cool", "stuff"], :link => "http://www.flowdock.com/")
106
139
  ```
@@ -111,25 +144,27 @@ flow.push_to_team_inbox(:subject => "Greetings from Flowdock API Gem!",
111
144
  require 'rubygems'
112
145
  require 'flowdock'
113
146
 
114
- # create a new Flow object with the api tokens of the target flows
115
- flow = Flowdock::Flow.new(:api_token => ["__FLOW_TOKEN__", "__ANOTHER_FLOW_TOKEN__"], ... )
147
+ # create a new Flow object with the API tokens of the target flows
148
+ flow = Flowdock::Flow.new(:api_token => ["__FLOW_API_TOKEN__", "__ANOTHER_FLOW_API_TOKEN__"], ... )
116
149
 
117
- # see above examples of posting to Chat or Team Inbox
150
+ # see the above examples of posting to the chat or team inbox
118
151
  ```
119
152
 
120
153
  ## API methods
121
154
 
122
155
  * `Flowdock::Flow` methods
123
156
 
124
- `push_to_team_inbox` - Send message to Team Inbox. See [API documentation](http://www.flowdock.com/api/team-inbox) for details.
157
+ `push_to_team_inbox` - Send message to the team inbox. See [API documentation](http://www.flowdock.com/api/team-inbox) for details.
125
158
 
126
- `push_to_chat` - Send message to Chat. See [API documentation](http://www.flowdock.com/api/chat) for details.
159
+ `push_to_chat` - Send message to the chat. See [API documentation](http://www.flowdock.com/api/chat) for details.
127
160
 
128
161
  `send_message(params)` - Deprecated. Please use `push_to_team_inbox` instead.
129
162
 
130
163
  * `Flowdock::Client` methods
131
164
 
132
- `chat_message` - Send message to Chat.
165
+ `chat_message` - Send message to chat.
166
+
167
+ `post_to_thread` - Post messages to a team inbox thread.
133
168
 
134
169
  `post`, `get`, `put`, `delete` - Send arbitary api calls. First parameter is the path, second is data. See [REST API documentation](http://www.flowdock.com/api/rest).
135
170
 
@@ -142,7 +177,7 @@ There are separate gems for deployment notifications:
142
177
 
143
178
  ## Changelog
144
179
 
145
- * 0.5.0 - Added `Flowdock::Client` that authenticates using user credentials and can be used to interact with the api. Better threads support for both `Flow` and `Client` so that comments can be made.
180
+ * 0.5.0 - Added `Flowdock::Client` that authenticates using user credentials and can be used to interact with the API. Better threads support for both `Flow` and `Client` so that comments can be made.
146
181
 
147
182
  ## Copyright
148
183
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.0
1
+ 0.7.0
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: flowdock 0.5.0 ruby lib
5
+ # stub: flowdock 0.7.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "flowdock"
9
- s.version = "0.5.0"
9
+ s.version = "0.7.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Antti Pitk\u{e4}nen"]
14
- s.date = "2014-09-23"
14
+ s.date = "2015-07-21"
15
15
  s.email = "team@flowdock.com"
16
16
  s.extra_rdoc_files = [
17
17
  "LICENSE",
@@ -34,7 +34,7 @@ Gem::Specification.new do |s|
34
34
  ]
35
35
  s.homepage = "http://github.com/flowdock/flowdock-api"
36
36
  s.licenses = ["MIT"]
37
- s.rubygems_version = "2.2.1"
37
+ s.rubygems_version = "2.4.1"
38
38
  s.summary = "Ruby Gem for using Flowdock's API"
39
39
 
40
40
  if s.respond_to? :specification_version then
@@ -132,10 +132,12 @@ module Flowdock
132
132
  attr_reader :api_token
133
133
  def initialize(options = {})
134
134
  @api_token = options[:api_token]
135
- raise InvalidParameterError, "Client must have :api_token attribute" if blank?(@api_token)
135
+ @flow_token = options[:flow_token]
136
+ raise InvalidParameterError, "Client must have :api_token or an :flow_token" if blank?(@api_token) && blank?(@flow_token)
136
137
  end
137
138
 
138
139
  def chat_message(params)
140
+ raise InvalidParameterError, "missing api_token" if blank?(@api_token)
139
141
  raise InvalidParameterError, "Message must have :content" if blank?(params[:content])
140
142
  raise InvalidParameterError, "Message must have :flow" if blank?(params[:flow])
141
143
  params = params.clone
@@ -147,17 +149,26 @@ module Flowdock
147
149
  end
148
150
 
149
151
  def private_message(params)
152
+ raise InvalidParameterError, "missing api_token" if blank?(@api_token)
150
153
  raise InvalidParameterError, "Message must have :content" if blank?(params[:content])
151
154
  raise InvalidParameterError, "Message must have :user_id" if blank?(params[:user_id])
152
155
 
153
156
  user_id = params.delete(:user_id)
154
-
157
+
155
158
  params = params.clone
156
159
  event = "message"
157
160
 
158
161
  post("private/#{user_id}/messages", params.merge(event: event))
159
162
  end
160
-
163
+
164
+ def post_to_thread(thread)
165
+ raise InvalidParameterError, "missing flow_token" if blank?(@flow_token)
166
+ resp = self.class.post(api_url("/messages"),
167
+ body: MultiJson.dump(thread.merge(flow_token: @flow_token)),
168
+ headers: headers)
169
+ handle_response resp
170
+ end
171
+
161
172
  def post(path, data = {})
162
173
  resp = self.class.post(api_url(path), :body => MultiJson.dump(data), :basic_auth => {:username => @api_token, :password => ''}, :headers => headers)
163
174
  handle_response(resp)
@@ -73,9 +73,10 @@ describe Flowdock do
73
73
  end
74
74
 
75
75
  it "should send without reply_to address" do
76
- lambda {
76
+ expect {
77
+ stub_request(:post, push_to_team_inbox_url(@token)).to_return(:body => "", :status => 200)
77
78
  @flow.push_to_team_inbox(@valid_attributes.merge(:reply_to => ""))
78
- }.should_not raise_error(Flowdock::InvalidParameterError)
79
+ }.not_to raise_error
79
80
  end
80
81
 
81
82
  it "should succeed with correct token, source and sender information" do
@@ -180,7 +181,7 @@ describe Flowdock do
180
181
  to_return(:body => "", :status => 200)
181
182
 
182
183
  @flow.push_to_team_inbox(:subject => "Hello World", :content => @example_content,
183
- :tags => ["cool", "stuff"], :link => "http://www.flowdock.com/").should be_true
184
+ :tags => ["cool", "stuff"], :link => "http://www.flowdock.com/").should be_truthy
184
185
  }.should_not raise_error
185
186
  end
186
187
 
@@ -201,7 +202,7 @@ describe Flowdock do
201
202
  to_return(:body => "", :status => 200)
202
203
 
203
204
  @flow.push_to_team_inbox(:subject => "Hello World", :content => @example_content, :tags => ["cool", "stuff"],
204
- :from => {:name => "Test", :address => "invalid@nodeta.fi"}, :reply_to => "foobar@example.com").should be_true
205
+ :from => {:name => "Test", :address => "invalid@nodeta.fi"}, :reply_to => "foobar@example.com").should be_truthy
205
206
  }.should_not raise_error
206
207
  end
207
208
 
@@ -256,7 +257,7 @@ describe Flowdock do
256
257
  with(:body => @valid_parameters.merge(:tags => "cool,stuff")).
257
258
  to_return(:body => "", :status => 200)
258
259
 
259
- @flow.push_to_chat(@valid_parameters).should be_true
260
+ @flow.push_to_chat(@valid_parameters).should be_truthy
260
261
  }.should_not raise_error
261
262
  end
262
263
 
@@ -335,111 +336,129 @@ end
335
336
 
336
337
  describe Flowdock::Client do
337
338
 
338
- let(:token) { SecureRandom.hex(8) }
339
- let(:client) { Flowdock::Client.new(api_token: token) }
340
-
341
- describe 'initializing' do
342
-
343
- it 'should initialize with access token' do
344
- expect {
345
- client = Flowdock::Client.new(api_token: token)
346
- expect(client.api_token).to equal(token)
347
- }.not_to raise_error
348
- end
349
- it 'should raise error if initialized without access token' do
350
- expect {
351
- client = Flowdock::Client.new(api_token: nil)
352
- }.to raise_error(Flowdock::InvalidParameterError)
353
- end
354
- end
355
-
356
- describe 'posting to chat' do
357
-
358
- let(:flow) { SecureRandom.hex(8) }
359
-
360
- it 'posts to /messages' do
361
- expect {
362
- stub_request(:post, "https://#{token}:@api.flowdock.com/v1/messages").
363
- with(:body => MultiJson.dump(flow: flow, content: "foobar", tags: [], event: "message"), :headers => {"Accept" => "application/json", "Content-Type" => "application/json"}).
364
- to_return(:status => 201, :body => '{"id":123}', :headers => {"Content-Type" => "application/json"})
365
- res = client.chat_message(flow: flow, content: 'foobar')
339
+ context "with flow_token" do
340
+ let(:token) { SecureRandom.hex }
341
+ let(:client) { Flowdock::Client.new(flow_token: token) }
342
+ let(:flow) { SecureRandom.hex }
343
+
344
+ describe "post a threaded message" do
345
+ it "succeeds" do
346
+ stub_request(:post, "https://api.flowdock.com/v1/messages").
347
+ with(body: MultiJson.dump(flow: flow, flow_token: token),
348
+ headers: {"Accept" => "application/json", "Content-Type" => "application/json"}).
349
+ to_return(status: 201, body: '{"id":123}', headers: {"Content-Type" => "application/json"})
350
+ res = client.post_to_thread({flow: flow})
366
351
  expect(res).to eq({"id" => 123})
367
- }.not_to raise_error
368
- end
369
- it 'posts to /comments' do
370
- expect {
371
- stub_request(:post, "https://#{token}:@api.flowdock.com/v1/comments").
372
- with(:body => MultiJson.dump(flow: flow, content: "foobar", message: 12345, tags: [], event: "comment"), :headers => {"Accept" => "application/json", "Content-Type" => "application/json"}).
373
- to_return(:status => 201, :body => '{"id":1234}', :headers => {"Content-Type" => "application/json"})
374
- res = client.chat_message(flow: flow, content: 'foobar', message: 12345)
375
- expect(res).to eq({"id" => 1234})
376
- }.not_to raise_error
377
- end
378
- it 'posts to /private/:user_id/messages' do
379
- expect {
380
- stub_request(:post, "https://#{token}:@api.flowdock.com/v1/private/12345/messages").
381
- with(:body => MultiJson.dump(content: "foobar", event: "message"), :headers => {"Accept" => "application/json", "Content-Type" => "application/json"}).
382
- to_return(:status => 201, :body => '{"id":1234}', :headers => {"Content-Type" => "application/json"})
383
- res = client.private_message(user_id: "12345", content: 'foobar')
384
- expect(res).to eq({"id" => 1234})
385
- }.not_to raise_error
352
+ end
386
353
  end
354
+ end
387
355
 
388
- it 'raises without flow' do
389
- expect {
390
- client.chat_message(content: 'foobar')
391
- }.to raise_error(Flowdock::InvalidParameterError)
392
- end
393
- it 'raises without content' do
394
- expect {
395
- client.chat_message(flow: flow)
396
- }.to raise_error(Flowdock::InvalidParameterError)
397
- end
398
- it 'handles error responses' do
399
- expect {
400
- stub_request(:post, "https://#{token}:@api.flowdock.com/v1/messages").
401
- to_return(:body => '{"message":"Validation error","errors":{"content":["can\'t be blank"],"external_user_name":["should not contain whitespace"]}}',
402
- :status => 400)
356
+ context "with api_token" do
357
+ let(:token) { SecureRandom.hex(8) }
358
+ let(:client) { Flowdock::Client.new(api_token: token) }
359
+
360
+ describe 'initializing' do
361
+
362
+ it 'should initialize with access token' do
363
+ expect {
364
+ client = Flowdock::Client.new(api_token: token)
365
+ expect(client.api_token).to equal(token)
366
+ }.not_to raise_error
367
+ end
368
+ it 'should raise error if initialized without access token' do
369
+ expect {
370
+ client = Flowdock::Client.new(api_token: nil)
371
+ }.to raise_error(Flowdock::InvalidParameterError)
372
+ end
373
+ end
374
+
375
+ describe 'posting to chat' do
376
+
377
+ let(:flow) { SecureRandom.hex(8) }
378
+
379
+ it 'posts to /messages' do
380
+ expect {
381
+ stub_request(:post, "https://#{token}:@api.flowdock.com/v1/messages").
382
+ with(:body => MultiJson.dump(flow: flow, content: "foobar", tags: [], event: "message"), :headers => {"Accept" => "application/json", "Content-Type" => "application/json"}).
383
+ to_return(:status => 201, :body => '{"id":123}', :headers => {"Content-Type" => "application/json"})
384
+ res = client.chat_message(flow: flow, content: 'foobar')
385
+ expect(res).to eq({"id" => 123})
386
+ }.not_to raise_error
387
+ end
388
+ it 'posts to /comments' do
389
+ expect {
390
+ stub_request(:post, "https://#{token}:@api.flowdock.com/v1/comments").
391
+ with(:body => MultiJson.dump(flow: flow, content: "foobar", message: 12345, tags: [], event: "comment"), :headers => {"Accept" => "application/json", "Content-Type" => "application/json"}).
392
+ to_return(:status => 201, :body => '{"id":1234}', :headers => {"Content-Type" => "application/json"})
393
+ res = client.chat_message(flow: flow, content: 'foobar', message: 12345)
394
+ expect(res).to eq({"id" => 1234})
395
+ }.not_to raise_error
396
+ end
397
+ it 'posts to /private/:user_id/messages' do
398
+ expect {
399
+ stub_request(:post, "https://#{token}:@api.flowdock.com/v1/private/12345/messages").
400
+ with(:body => MultiJson.dump(content: "foobar", event: "message"), :headers => {"Accept" => "application/json", "Content-Type" => "application/json"}).
401
+ to_return(:status => 201, :body => '{"id":1234}', :headers => {"Content-Type" => "application/json"})
402
+ res = client.private_message(user_id: "12345", content: 'foobar')
403
+ expect(res).to eq({"id" => 1234})
404
+ }.not_to raise_error
405
+ end
406
+
407
+ it 'raises without flow' do
408
+ expect {
409
+ client.chat_message(content: 'foobar')
410
+ }.to raise_error(Flowdock::InvalidParameterError)
411
+ end
412
+ it 'raises without content' do
413
+ expect {
414
+ client.chat_message(flow: flow)
415
+ }.to raise_error(Flowdock::InvalidParameterError)
416
+ end
417
+ it 'handles error responses' do
418
+ expect {
419
+ stub_request(:post, "https://#{token}:@api.flowdock.com/v1/messages").
420
+ to_return(:body => '{"message":"Validation error","errors":{"content":["can\'t be blank"],"external_user_name":["should not contain whitespace"]}}',
421
+ :status => 400)
403
422
  client.chat_message(flow: flow, content: 'foobar')
404
- }.to raise_error(Flowdock::ApiError)
423
+ }.to raise_error(Flowdock::ApiError)
424
+ end
405
425
  end
406
- end
407
426
 
408
- describe 'GET' do
409
- it 'does abstract get with params' do
410
- stub_request(:get, "https://#{token}:@api.flowdock.com/v1/some_path?sort_by=date").
411
- with(:headers => {'Accept'=>'application/json', 'Content-Type'=>'application/json'}).
412
- to_return(:status => 200, :body => '{"id": 123}', :headers => {"Content-Type" => "application/json"})
413
- expect(client.get('/some_path', {sort_by: 'date'})).to eq({"id" => 123})
427
+ describe 'GET' do
428
+ it 'does abstract get with params' do
429
+ stub_request(:get, "https://#{token}:@api.flowdock.com/v1/some_path?sort_by=date").
430
+ with(:headers => {'Accept'=>'application/json', 'Content-Type'=>'application/json'}).
431
+ to_return(:status => 200, :body => '{"id": 123}', :headers => {"Content-Type" => "application/json"})
432
+ expect(client.get('/some_path', {sort_by: 'date'})).to eq({"id" => 123})
433
+ end
414
434
  end
415
- end
416
435
 
417
- describe 'POST' do
418
- it 'does abstract post with body' do
419
- stub_request(:post, "https://#{token}:@api.flowdock.com/v1/other_path").
420
- with(:headers => {'Accept'=>'application/json', 'Content-Type'=>'application/json'}, :body => MultiJson.dump(name: 'foobar')).
421
- to_return(:status => 200, :body => '{"id": 123,"name": "foobar"}', :headers => {"Content-Type" => "application/json"})
422
- expect(client.post('other_path', {name: 'foobar'})).to eq({"id" => 123, "name" => "foobar"})
423
- end
436
+ describe 'POST' do
437
+ it 'does abstract post with body' do
438
+ stub_request(:post, "https://#{token}:@api.flowdock.com/v1/other_path").
439
+ with(:headers => {'Accept'=>'application/json', 'Content-Type'=>'application/json'}, :body => MultiJson.dump(name: 'foobar')).
440
+ to_return(:status => 200, :body => '{"id": 123,"name": "foobar"}', :headers => {"Content-Type" => "application/json"})
441
+ expect(client.post('other_path', {name: 'foobar'})).to eq({"id" => 123, "name" => "foobar"})
442
+ end
424
443
 
425
- end
444
+ end
426
445
 
427
- describe 'PUT' do
428
- it 'does abstract put with body' do
429
- stub_request(:put, "https://#{token}:@api.flowdock.com/v1/other_path").
430
- with(:headers => {'Accept'=>'application/json', 'Content-Type'=>'application/json'}, :body => MultiJson.dump(name: 'foobar')).
431
- to_return(:status => 200, :body => '{"id": 123,"name": "foobar"}', :headers => {"Content-Type" => "application/json"})
432
- expect(client.put('other_path', {name: 'foobar'})).to eq({"id" => 123, "name" => "foobar"})
446
+ describe 'PUT' do
447
+ it 'does abstract put with body' do
448
+ stub_request(:put, "https://#{token}:@api.flowdock.com/v1/other_path").
449
+ with(:headers => {'Accept'=>'application/json', 'Content-Type'=>'application/json'}, :body => MultiJson.dump(name: 'foobar')).
450
+ to_return(:status => 200, :body => '{"id": 123,"name": "foobar"}', :headers => {"Content-Type" => "application/json"})
451
+ expect(client.put('other_path', {name: 'foobar'})).to eq({"id" => 123, "name" => "foobar"})
452
+ end
433
453
  end
434
- end
435
454
 
436
- describe 'DELETE' do
437
- it 'does abstract delete with params' do
438
- stub_request(:delete, "https://#{token}:@api.flowdock.com/v1/some_path").
439
- with(:headers => {'Accept'=>'application/json', 'Content-Type'=>'application/json'}).
440
- to_return(:status => 200, :body => '', :headers => {"Content-Type" => "application/json"})
441
- expect(client.delete('/some_path')).to eq({})
455
+ describe 'DELETE' do
456
+ it 'does abstract delete with params' do
457
+ stub_request(:delete, "https://#{token}:@api.flowdock.com/v1/some_path").
458
+ with(:headers => {'Accept'=>'application/json', 'Content-Type'=>'application/json'}).
459
+ to_return(:status => 200, :body => '', :headers => {"Content-Type" => "application/json"})
460
+ expect(client.delete('/some_path')).to eq({})
461
+ end
442
462
  end
443
463
  end
444
-
445
464
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flowdock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Antti Pitkänen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-11 00:00:00.000000000 Z
11
+ date: 2015-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -163,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
163
  version: '0'
164
164
  requirements: []
165
165
  rubyforge_project:
166
- rubygems_version: 2.2.1
166
+ rubygems_version: 2.4.1
167
167
  signing_key:
168
168
  specification_version: 4
169
169
  summary: Ruby Gem for using Flowdock's API