Class: PaperCallClient
- Inherits:
-
Object
- Object
- PaperCallClient
- Includes:
- HTTParty
- Defined in:
- lib/papercallio/client.rb
Instance Method Summary collapse
- #event ⇒ Object
- #feedback(id) ⇒ Object
-
#initialize(api_token, query_options) ⇒ PaperCallClient
constructor
A new instance of PaperCallClient.
- #rating(id) ⇒ Object
- #submission(id) ⇒ Object
- #submissions ⇒ Object
Constructor Details
#initialize(api_token, query_options) ⇒ PaperCallClient
Returns a new instance of PaperCallClient.
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/papercallio/client.rb', line 7 def initialize(api_token, ) raise 'must set `export PAPERCALL_API_TOKEN=abcdefghijklmnopqrstuvwxyz1234567890` to call the API. See help.' if api_token.nil? @query = { # page: page, # TODO: for first iteration, just going to hardcode to 9999 per_page: 9999 } @query[:state] = [:state] if [:state] @query[:keywords] = [:keywords] if [:keywords] @query[:needs_rating] = [:needs_rating] if [:needs_rating] @query[:order] = [:order] if [:order] @options = { query: @query, headers: { 'Authorization' => api_token } } end |
Instance Method Details
#event ⇒ Object
21 22 23 |
# File 'lib/papercallio/client.rb', line 21 def event self.class.get("/api/v1/event", @options) end |
#feedback(id) ⇒ Object
38 39 40 |
# File 'lib/papercallio/client.rb', line 38 def feedback(id) self.class.get("/api/v1/submissions/#{id}/feedback", @options) end |
#rating(id) ⇒ Object
33 34 35 36 |
# File 'lib/papercallio/client.rb', line 33 def (id) response = self.class.get("/api/v1/submissions/#{id}/ratings", @options) response.success? ? response : [] end |
#submission(id) ⇒ Object
29 30 31 |
# File 'lib/papercallio/client.rb', line 29 def submission(id) self.class.get("/api/v1/submissions/#{id}", @options) end |
#submissions ⇒ Object
25 26 27 |
# File 'lib/papercallio/client.rb', line 25 def submissions self.class.get("/api/v1/submissions", @options) end |