Class: PaperCallClient

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/papercallio/client.rb

Instance Method Summary collapse

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, query_options)
  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] = query_options[:state] if query_options[:state]
  @query[:keywords] = query_options[:keywords] if query_options[:keywords]
  @query[:needs_rating] = query_options[:needs_rating] if query_options[:needs_rating]
  @query[:order] = query_options[:order] if query_options[:order]
  @options = { query: @query, headers: { 'Authorization' => api_token } }
end

Instance Method Details

#eventObject



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 rating(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

#submissionsObject



25
26
27
# File 'lib/papercallio/client.rb', line 25

def submissions
  self.class.get("/api/v1/submissions", @options)
end