croudia 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MmU2ZDc5NjMxNmJjMTkxNGY4NTc5MzY2NzMxYjI5Mzk5ZTc4YWJiMA==
4
+ M2ZlNGY3ZWJhMGUwODEwNGE3MjcyNmE0YmQ2YjBmMzk2YWQyMTM4Yg==
5
5
  data.tar.gz: !binary |-
6
- NTYyMWRlMjZkMGU0MzRkM2RmYTRiNmJmNmU5OGNiNTdmOWNkYjY0MQ==
6
+ YTg0ZTA2MzY2MDhkNzNmMDE1OGQ4MTYxYjA0ZmY3NTM1ZTFmMDhkNw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZTRiZTkyMDRmMmJlZTE5OTE4MWUyNTIwMDVjYTQyZTc4NWE0MjNmYTFiZTIw
10
- NGViODgzMTAwZWIyYzFmZTkxMGNjY2ZmOWYwYjY3NDA2MDhiNGVjNGNmOWUy
11
- YzJkODNlZTQ1NDAwZjZkYmZkMzY5ZWUzOGQ3MjAwNTFlMjYwMTk=
9
+ Y2QzZDAzYjdlOGY5MGE4MjY1NWVjZjY4MmI4OWQwNmYxZTczNWU0NTc2MDIx
10
+ YjgwNzAzZTM1MmQ5NzdiNjYyOWFhZDY5Y2M4NDdjMjU5MGRiOTZlZmEyM2Rl
11
+ ODMyZTZlZGJkNmYxZjQ0ODFjMmQ1MWZhZGUyMTdhMzBkODY2NDM=
12
12
  data.tar.gz: !binary |-
13
- YmRhZTQ0M2ZlMzA2ODNkNDUzYzM1N2Y1MDViMjVhYTBkYjkyNGVmZjIzZTVi
14
- NzFiZDFmOWU5NzQ1NmE4MTdiMzY2MDRmZGM1OTc1OWE1MDFlZWFlODA0MjRm
15
- ZmVlZDQ1NWUwZTY0ZmZhODI3MTc4NmYzOTMzZmYzN2JjMWE1MDk=
13
+ ZWUzNDlhYTk1OWEwZWRhZDk0NjM3ZjY4MjFiNDlkYTRkM2RjN2YzZTg3NDQy
14
+ MTc3M2I5MWZkZmY2MjUwYWUxMDk1ZWI5MTJlNTIwZjc2NzIzNjU2OGRiZTBi
15
+ MGRjMGYwNDAwMTc5YmIxMGEzNmYzYTk0N2ZkMmY3NjY3YjBlZDY=
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Build Status](https://travis-ci.org/wktk/croudia-gem.png)](https://travis-ci.org/wktk/croudia-gem)
4
4
 
5
- A Ruby Wapper for the [Croudia](https://croudia.com) API
5
+ Ruby wrapper for the [Croudia](https://croudia.com) API
6
6
 
7
7
  This software is not affiliated with [Croudia Inc](http://croudia.co.jp/).
8
8
  Croudia is a registered trademark of Croudia Inc. in Japan.
data/croudia.gemspec CHANGED
@@ -3,8 +3,8 @@ require File.expand_path('../lib/croudia/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.authors = ['wktk']
6
- gem.email = ['mail@wktk.jp']
7
- gem.description = 'Ruby Wrapper for the Croudia API'
6
+ gem.email = ['wktk30@gmail.com']
7
+ gem.description = 'Ruby wrapper for the Croudia API'
8
8
  gem.summary = 'Croudia API'
9
9
  gem.homepage = 'https://github.com/wktk/croudia-gem'
10
10
  gem.license = 'MIT'
@@ -50,6 +50,30 @@ module Croudia
50
50
  Croudia::SecretMail.new(resp)
51
51
  end
52
52
 
53
+ # Send a new secret mail with media
54
+ #
55
+ # @see https://developer.croudia.com/docs/26_secret_mails_new_with_media
56
+ # @overload send_secret_mail_with_media(text, to_user, media, params={})
57
+ # @param [String] text Message body
58
+ # @param [String, Integer, Croudia::User] to_user Recipient user
59
+ # @param [File, #to_io] media Image to upload with
60
+ # @param [Hash] params Additional query parameters
61
+ # @overload send_secret_mail_with_media(params={})
62
+ # @param [Hash] params Query parameters
63
+ # @option params [File, #to_io] :media Image to upload with
64
+ # @option params [String] :screen_name Screen name of the recipient
65
+ # @option params [String] :text Message body
66
+ # @option params [String, Integer] :user_id ID of the recipient
67
+ # @return [Croudia::SecretMail] Sent message
68
+ def send_secret_mail_with_media(text, to_user={}, media={}, params={})
69
+ merge_text!(params, text, :text)
70
+ merge_user!(params, to_user)
71
+ merge_file!(params, media, :media)
72
+
73
+ resp = post('/secret_mails/new_with_media.json')
74
+ Croudia::SecretMail.new(resp)
75
+ end
76
+
53
77
  # Destroy a secret mail
54
78
  #
55
79
  # @see https://developer.croudia.com/docs/24_secret_mails_destroy
@@ -71,6 +95,16 @@ module Croudia
71
95
  resp = get("/secret_mails/show/#{get_id(id)}.json", params)
72
96
  Croudia::SecretMail.new(resp)
73
97
  end
98
+
99
+ # Get an image attached to a secret mail
100
+ #
101
+ # @see https://developer.croudia.com/docs/27_secret_mails_get_secret_photo
102
+ # @param [String, Integer] id Image ID
103
+ # @return [String] Raw image
104
+ def secret_photo(id)
105
+ get("/secret_mails/get_secret_photo/#{id}")
106
+ end
107
+
74
108
  end
75
109
  end
76
110
  end
@@ -5,6 +5,8 @@ module Croudia
5
5
  module Response
6
6
  class ParseJSON < Faraday::Response::Middleware
7
7
  def on_complete(env)
8
+ return unless env[:response_headers]['content-type'].to_s.include?('json')
9
+
8
10
  case env[:body]
9
11
  when /\A\s*\z/, nil
10
12
  env[:body] = nil
@@ -12,8 +14,7 @@ module Croudia
12
14
  env[:body] = JSON.parse(env[:body])
13
15
  end
14
16
  rescue JSON::ParserError => e
15
- raise e if env[:status] == 200
16
- env[:body] = nil
17
+ env[:status] == 200 ? raise(e) : env[:body] = nil
17
18
  end
18
19
  end
19
20
  end
@@ -1,3 +1,3 @@
1
1
  module Croudia
2
- VERSION = '1.4.0'
2
+ VERSION = '1.5.0'
3
3
  end
@@ -9,7 +9,7 @@ describe Croudia::API::Account do
9
9
  before do
10
10
  stub_get('/account/verify_credentials.json').to_return(
11
11
  body: fixture(:user),
12
- header: { content_type: 'application/json; charset=utf-8' }
12
+ headers: { content_type: 'application/json; charset=utf-8' }
13
13
  )
14
14
  end
15
15
 
@@ -94,7 +94,7 @@ describe Croudia::API::Friendships do
94
94
  }
95
95
  ).to_return(
96
96
  body: fixture(:friendship),
97
- headers: { content_type: 'appplication/json; charset=utf-8' }
97
+ headers: { content_type: 'application/json; charset=utf-8' }
98
98
  )
99
99
  end
100
100
 
@@ -9,7 +9,7 @@ describe Croudia::API::SecretMails do
9
9
  before do
10
10
  stub_get('/secret_mails.json').to_return(
11
11
  body: fixture(:secret_mails),
12
- header: { content_type: 'application/json; charset=utf-8' }
12
+ headers: { content_type: 'application/json; charset=utf-8' }
13
13
  )
14
14
  end
15
15
 
@@ -29,7 +29,7 @@ describe Croudia::API::SecretMails do
29
29
  before do
30
30
  stub_get('/secret_mails/sent.json').to_return(
31
31
  body: fixture(:secret_mails),
32
- header: { content_type: 'application/json; charset=utf-8' }
32
+ headers: { content_type: 'application/json; charset=utf-8' }
33
33
  )
34
34
  end
35
35
 
@@ -109,11 +109,30 @@ describe Croudia::API::SecretMails do
109
109
  end
110
110
  end
111
111
 
112
+ describe '#send_secret_mail_with_media' do
113
+ before do
114
+ stub_post('/secret_mails/new_with_media.json').to_return(
115
+ body: fixture(:secret_mail),
116
+ headers: { content_type: 'application/json; charset=utf-8' }
117
+ )
118
+ end
119
+
120
+ it 'requests the correct resource' do
121
+ @client.send_secret_mail_with_media('hi', 1234, fixture('image.jpg'))
122
+ expect(a_post('/secret_mails/new_with_media.json')).to have_been_made
123
+ end
124
+
125
+ it 'returns Croudia::SecretMail' do
126
+ subject = @client.send_secret_mail_with_media('hi', 1234, fixture('image.jpg'))
127
+ expect(subject).to be_a Croudia::SecretMail
128
+ end
129
+ end
130
+
112
131
  describe '#destroy_secret_mail' do
113
132
  before do
114
133
  stub_post('/secret_mails/destroy/1234.json').to_return(
115
134
  body: fixture(:secret_mail),
116
- headers: { content_type: 'application/json; charset-utf-8' }
135
+ headers: { content_type: 'application/json; charset=utf-8' }
117
136
  )
118
137
  end
119
138
 
@@ -137,7 +156,7 @@ describe Croudia::API::SecretMails do
137
156
  before do
138
157
  stub_get('/secret_mails/show/1234.json').to_return(
139
158
  body: fixture(:secret_mail),
140
- headers: { content_type: 'appplication/json; charset=utf-8' }
159
+ headers: { content_type: 'application/json; charset=utf-8' }
141
160
  )
142
161
  end
143
162
 
@@ -151,4 +170,23 @@ describe Croudia::API::SecretMails do
151
170
  expect(subject).to be_a Croudia::SecretMail
152
171
  end
153
172
  end
173
+
174
+ describe '#secret_photo' do
175
+ before do
176
+ stub_get('/secret_mails/get_secret_photo/123').to_return(
177
+ body: fixture('image.jpg'),
178
+ headers: { content_type: 'image/jpg' }
179
+ )
180
+ end
181
+
182
+ it 'requests the correct resource' do
183
+ @client.secret_photo(123)
184
+ expect(a_get('/secret_mails/get_secret_photo/123')).to have_been_made
185
+ end
186
+
187
+ it 'returns a photo in String' do
188
+ expect(@client.secret_photo(123)).to eq fixture('image.jpg').read
189
+ end
190
+ end
191
+
154
192
  end
@@ -99,7 +99,7 @@ describe Croudia::API::Statuses do
99
99
  before do
100
100
  stub_get('/statuses/show/1234.json').to_return(
101
101
  body: fixture(:status),
102
- header: { content_type: 'application/json; charset=utf-8' }
102
+ headers: { content_type: 'application/json; charset=utf-8' }
103
103
  )
104
104
  end
105
105
 
@@ -117,7 +117,7 @@ describe Croudia::API::Statuses do
117
117
  before do
118
118
  stub_post('/statuses/spread/1234.json').to_return(
119
119
  body: fixture(:status),
120
- header: { content_type: 'application/json: charset=utf-8' }
120
+ headers: { content_type: 'application/json: charset=utf-8' }
121
121
  )
122
122
  end
123
123
 
data/spec/croudia_spec.rb CHANGED
@@ -5,7 +5,7 @@ describe Croudia do
5
5
  before do
6
6
  stub_get('/statuses/public_timeline.json').to_return(
7
7
  body: fixture('timeline'),
8
- headers: { content_type: 'application/json; charset_utf-8' }
8
+ headers: { content_type: 'application/json; charset=utf-8' }
9
9
  )
10
10
  end
11
11
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: croudia
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - wktk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-22 00:00:00.000000000 Z
11
+ date: 2014-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -94,9 +94,9 @@ dependencies:
94
94
  - - ~>
95
95
  - !ruby/object:Gem::Version
96
96
  version: 1.13.0
97
- description: Ruby Wrapper for the Croudia API
97
+ description: Ruby wrapper for the Croudia API
98
98
  email:
99
- - mail@wktk.jp
99
+ - wktk30@gmail.com
100
100
  executables: []
101
101
  extensions: []
102
102
  extra_rdoc_files: []