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".freeze

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



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/noun-project-api/reporter.rb', line 8

def report_used(ids)
  ids = [ids] if ids.is_a?(String) || ids.is_a?(Fixnum)
  fail(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