Class: NounProjectApi::Reporter

Inherits:
Object
  • Object
show all
Includes:
Connection
Defined in:
lib/noun_project_api/reporter.rb

Overview

Main class to hold reporting actions back to the Noun Project.

Constant Summary collapse

API_PATH =
"/notify/publish"

Instance Attribute Summary

Attributes included from Connection

#access_token, #secret, #token

Instance Method Summary collapse

Methods included from Connection

#initialize

Instance Method Details

#report_used(ids) ⇒ Object

Raises:

  • (ArgumentError)


10
11
12
13
14
15
16
17
18
19
20
# File 'lib/noun_project_api/reporter.rb', line 10

def report_used(ids)
  ids = [ids] if ids.is_a?(String) || ids.is_a?(Integer)
  raise ArgumentError, "Missing ids" if ids.nil? || ids.empty?

  result = access_token.post(
    "#{API_BASE}#{API_PATH}",
    { icons: ids.join(",") }.to_json,
    "Accept" => "application/json", "Content-Type" => "application/json"
  )
  result.code == "200"
end