Class: Camp3::Client

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Authorization, CommentAPI, MessageAPI, ProjectAPI, ResourceAPI, TodoAPI, Logging
Defined in:
lib/camp3/client.rb,
lib/camp3/api/todo.rb,
lib/camp3/api/comment.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: CommentAPI, MessageAPI, ProjectAPI, ResourceAPI, TodoAPI

Instance Attribute Summary

Attributes included from Logging

#logger

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 CommentAPI

#add_comment, #comments

Methods included from Authorization

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

Constructor Details

#initialize(options = {}) ⇒ Client

Creates a new API.

Raises:

  • (Error:MissingCredentials)


24
25
26
# File 'lib/camp3/client.rb', line 24

def initialize(options = {})
  @config = Configuration.new(options)
end

Instance Method Details

#configure {|@config| ... } ⇒ Object

Allows setting configuration values for this client returns the client instance being configured

Yields:

  • (@config)


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

def configure
  yield @config

  self
end

#inspectString

Text representation of the client, masking private token.

Returns:

  • (String)


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

def inspect
  inspected = super
  inspected.sub! @config.access_token, only_show_last_four_chars(@config.access_token) if @config.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)


61
62
63
# File 'lib/camp3/client.rb', line 61

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