Class: Camp3::Client

Inherits:
Object
  • Object
show all
Includes:
Authorization, MessageAPI, ProjectAPI, ResourceAPI, TodoAPI
Defined in:
lib/camp3/client.rb,
lib/camp3/api/todo.rb,
lib/camp3/api/message.rb,
lib/camp3/api/project.rb,
lib/camp3/api/resource.rb

Overview

Wrapper for the Camp3 REST API.

Defined Under Namespace

Modules: MessageAPI, ProjectAPI, ResourceAPI, TodoAPI

Instance Method Summary collapse

Methods included from TodoAPI

#todolists, #todos

Methods included from ResourceAPI

#resource

Methods included from ProjectAPI

#message_board, #projects, #todoset

Methods included from MessageAPI

#messages

Methods included from Authorization

#authorization_uri, #authorize!, #authz_client, #update_access_token!

Constructor Details

#initialize(options = {}) ⇒ Client

Creates a new API.

Raises:

  • (Error:MissingCredentials)


20
21
22
23
24
25
26
# File 'lib/camp3/client.rb', line 20

def initialize(options = {})
  options = Camp3.options.merge(options)
  
  (Configuration::VALID_OPTIONS_KEYS).each do |key|
    send("#{key}=", options[key]) if options[key]
  end
end

Instance Method Details

#inspectString

Text representation of the client, masking private token.

Returns:

  • (String)


43
44
45
46
47
# File 'lib/camp3/client.rb', line 43

def inspect
  inspected = super
  inspected.sub! @access_token, only_show_last_four_chars(@access_token) if @access_token
  inspected
end

#url_encode(url) ⇒ String

Utility method for URL encoding of a string. Copied from ruby-doc.org/stdlib-2.7.0/libdoc/erb/rdoc/ERB/Util.html

Returns:

  • (String)


53
54
55
# File 'lib/camp3/client.rb', line 53

def url_encode(url)
  url.to_s.b.gsub(/[^a-zA-Z0-9_\-.~]/n) { |m| sprintf('%%%02X', m.unpack1('C')) } # rubocop:disable Style/FormatString, Style/FormatStringToken
end