Module: Copy

Defined in:
lib/copy.rb,
lib/copy/base.rb,
lib/copy/file.rb,
lib/copy/link.rb,
lib/copy/user.rb,
lib/copy/client.rb,
lib/copy/session.rb,
lib/copy/version.rb,
lib/copy/revision.rb,
lib/copy/request/base.rb,
lib/copy/request/info.rb,
lib/copy/operations/all.rb,
lib/copy/operations/base.rb,
lib/copy/operations/find.rb,
lib/copy/operations/meta.rb,
lib/copy/operations/show.rb,
lib/copy/request/helpers.rb,
lib/copy/operations/create.rb,
lib/copy/operations/delete.rb,
lib/copy/operations/update.rb,
lib/copy/request/validator.rb,
lib/copy/request/connection.rb,
lib/copy/operations/activity.rb

Defined Under Namespace

Modules: Operations, Request Classes: APIError, AuthenticationError, BadRequest, Base, Client, CopyError, File, Link, NotFound, ObjectNotFound, Revision, Session, User

Constant Summary collapse

DOMAIN_BASE =
'api'
API_BASE =
'copy.com'
API_BASE_PATH =
'rest'
API_VERSION =
'1'
ROOT_PATH =
File.dirname(__FILE__)
VERSION =
"0.0.1"
@@configuration =
{}

Class Method Summary collapse

Class Method Details

.config {|@@configuration| ... } ⇒ String

Gives configuration abilities to setup api_key and api_secret

Examples:

Copy.config do |configuration|
  configuration[:api_key] = '_your_api_key'
  configuration[:api_secret] = '_your_api_secret'
end

Yields:

Returns:

  • (String)

    The api key



61
62
63
64
# File 'lib/copy.rb', line 61

def self.config(&block)
  yield(@@configuration)
  @@configuration
end

.configurationObject



66
67
68
# File 'lib/copy.rb', line 66

def self.configuration
  @@configuration
end

.configuration=(value) ⇒ Object



70
71
72
# File 'lib/copy.rb', line 70

def self.configuration=(value)
  @@configuration = value
end

.request(http_method, domain, api_url, data, options = {}) ⇒ Array

Makes a request against the Copy API

Parameters:

  • http_method (Symbol)

    The http method to use, must be one of :get, :post, :put and :delete

  • domain (String)

    The API domain to use

  • api_url (String)

    The API url to use

  • data (Hash)

    The data to send, e.g. used when creating new objects.

Returns:

  • (Array)

    The parsed JSON response.



81
82
83
84
# File 'lib/copy.rb', line 81

def self.request(http_method, domain, api_url, data, options={})
  info = Request::Info.new(http_method, domain, api_url, data, options)
  Request::Base.new(info).perform
end