proz 0.3.1 → 1.0.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: 72ba9471d2c1fefc74eba134a9181e051fee733f
4
- data.tar.gz: e53558d5a1e88532a3b1e835521025a0671e3faa
3
+ metadata.gz: 6367453ab1a5c9097d24f789a1483f24f27e22b0
4
+ data.tar.gz: cdc37ca31e412e4d18d31d5351acbe598415920b
5
5
  SHA512:
6
- metadata.gz: e7f32214adef41f04cc7a7f8385b3646c236a9a8d5290db61292cd87f69f23f8b3bea10da28d8c44e3cafa186e759df3fca7629d0aba493baf6457a73726c6b3
7
- data.tar.gz: 4d384d02fe9e3259aa6d4313df15844112d0ce345ebba6ed5fcd133a87bf0d3572553b661e77e06206dea3dabffad0f0d6c8694dabdf5ea0ddbd27e64a8e19a1
6
+ metadata.gz: f40122fe7d4e9e908f0c68b29fa077e199f943e66e26c0b1c53cefa8b60d4effddcd28c98eb62b850e891f1674025b76e8fbd38590b23ff6177fa5591523f4c1
7
+ data.tar.gz: 9dfe889444c2f76da5ba712b0ad1a6cd58d1134e49cc513e314dce652ae81ec8a271c2cc9dc467dc1ba0f417ced7205c227964c10ef1d4b964a0732ae9a7d02f
data/README.md CHANGED
@@ -155,6 +155,38 @@ wiwo.entries
155
155
  # { ... }
156
156
  # ]
157
157
  # }
158
+
159
+
160
+ wiwo = Proz::WiwoEntries.new(key: 'yourAPIkey')
161
+ # Filter the returned WIWOs
162
+ # Options include:
163
+ # * user_uuid (string)
164
+ # * message_contains (string)
165
+ # * min_time (datetime)
166
+
167
+ options = {
168
+ user_uuid: '7ccfee74-a2a4-484f-8dbc-215a67026ce1',
169
+ message_contains: 'hello world',
170
+ min_time: '2016-07-013T01:01:01+00:00'
171
+ }
172
+ wiwo.filtered_entries(options)
173
+ ```
174
+
175
+ GET WIWO (OAuth2)
176
+
177
+ ```ruby
178
+ # Get user's WIWOs (public + private)
179
+ Proz::GetWiwoEntry.new(
180
+ token: 'access_token',
181
+ include_private: true
182
+ ).get
183
+
184
+ # Get user's WIWOs (public only)
185
+ Proz::GetWiwoEntry.new(
186
+ token: 'access_token',
187
+ include_private: false
188
+ ).get
189
+
158
190
  ```
159
191
 
160
192
  POST WIWO
@@ -172,7 +204,7 @@ Send a JSON object with the following fields. Only the "message" is required.
172
204
  * cat_tool (string) - A free-text name of the CAT tool in use, if any.
173
205
 
174
206
  ```
175
- Proz::WiwoEntry.new(
207
+ Proz::PostWiwoEntry.new(
176
208
  token: 'access_token',
177
209
  message: "Hello World",
178
210
  source_language: "eng",
@@ -190,11 +222,13 @@ POST Reply
190
222
  Uses OAuth2 with the `wiwo.post` default scope. Use the [omniauth-proz](https://github.com/diasks2/omniauth-proz) gem to easily authenticate.
191
223
 
192
224
  Send a JSON object with the following fields. Only the "message" is required.
225
+ * id (string) - id of the parent wiwo
193
226
  * message (string) - a plain text message.
194
227
  * message_language (string) - a 3-character language code for the message.
195
228
 
196
229
  ```
197
- Proz::WiwoReply.new(
230
+ Proz::PostWiwoReply.new(
231
+ id: '567',
198
232
  token: 'access_token',
199
233
  message: "Hello World",
200
234
  message_language: "eng"
@@ -3,6 +3,7 @@ require "proz/oauth"
3
3
  require "proz/profile"
4
4
  require "proz/freelancer"
5
5
  require "proz/freelancer_matches"
6
- require "proz/wiwo_entry"
6
+ require "proz/post_wiwo_entry"
7
+ require "proz/get_wiwo_entry"
7
8
  require "proz/wiwo_entries"
8
- require "proz/wiwo_reply"
9
+ require "proz/post_wiwo_reply"
@@ -0,0 +1,23 @@
1
+ require 'httparty'
2
+
3
+ module Proz
4
+ class GetWiwoEntry
5
+ include HTTParty
6
+ base_uri "https://api.proz.com/v2"
7
+ attr_reader :token, :include_private
8
+ def initialize(token:, include_private:)
9
+ @token = token
10
+ @include_private = include_private
11
+ end
12
+
13
+ def get
14
+ if include_private
15
+ self.class.get("/wiwo?include_private=1",
16
+ headers: { 'Authorization' => "Bearer #{token}" } )
17
+ else
18
+ self.class.get("/wiwo",
19
+ headers: { 'Authorization' => "Bearer #{token}" } )
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,7 +1,7 @@
1
1
  require 'httparty'
2
2
 
3
3
  module Proz
4
- class WiwoEntry
4
+ class PostWiwoEntry
5
5
  include HTTParty
6
6
  base_uri "https://api.proz.com/v2"
7
7
  attr_reader :token, :message, :options
@@ -1,7 +1,7 @@
1
1
  require 'httparty'
2
2
 
3
3
  module Proz
4
- class WiwoReply
4
+ class PostWiwoReply
5
5
  include HTTParty
6
6
  base_uri "https://api.proz.com/v2"
7
7
  attr_reader :token, :id, :message, :options
@@ -1,3 +1,3 @@
1
1
  module Proz
2
- VERSION = "0.3.1"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -1,4 +1,5 @@
1
1
  require 'httparty'
2
+ require 'uri'
2
3
 
3
4
  module Proz
4
5
  class WiwoEntries
@@ -21,8 +22,23 @@ module Proz
21
22
  all_wiwos["users"]
22
23
  end
23
24
 
24
- def user_entries(user_uuid)
25
- self.class.get("/wiwo?user_uuid=" + user_uuid, headers: { 'X-Proz-API-Key' => key })
25
+ def filtered_entries(**options)
26
+ if options[:user_uuid]
27
+ user_uuid_query = "user_uuid=" + options[:user_uuid] + '&'
28
+ else
29
+ user_uuid_query = ""
30
+ end
31
+ if options[:keyword]
32
+ keyword_query = "message_contains=" + URI.encode(options[:keyword], /\W/) + '&'
33
+ else
34
+ keyword_query = ""
35
+ end
36
+ if options[:min_time]
37
+ min_time_query = "min_time=" + URI.encode(options[:min_time]) + '&'
38
+ else
39
+ min_time_query = ""
40
+ end
41
+ self.class.get("/wiwo?" + user_uuid_query + keyword_query + min_time_query, headers: { 'X-Proz-API-Key' => key })
26
42
  end
27
43
 
28
44
  private
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin S. Dias
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-13 00:00:00.000000000 Z
11
+ date: 2016-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -140,12 +140,13 @@ files:
140
140
  - lib/proz.rb
141
141
  - lib/proz/freelancer.rb
142
142
  - lib/proz/freelancer_matches.rb
143
+ - lib/proz/get_wiwo_entry.rb
143
144
  - lib/proz/oauth.rb
145
+ - lib/proz/post_wiwo_entry.rb
146
+ - lib/proz/post_wiwo_reply.rb
144
147
  - lib/proz/profile.rb
145
148
  - lib/proz/version.rb
146
149
  - lib/proz/wiwo_entries.rb
147
- - lib/proz/wiwo_entry.rb
148
- - lib/proz/wiwo_reply.rb
149
150
  - proz.gemspec
150
151
  - spec/fixtures/vcr_cassettes/exchange_code_for_token.yml
151
152
  - spec/fixtures/vcr_cassettes/exchange_code_for_token_invalid_code.yml