Class: Trell::Client

Inherits:
Object
  • Object
show all
Includes:
Authentication, Boards, Cards, Labels, Lists, Members, Organizations, Tokens, Configurable
Defined in:
lib/trell/client.rb,
lib/trell/client/cards.rb,
lib/trell/client/lists.rb,
lib/trell/client/boards.rb,
lib/trell/client/labels.rb,
lib/trell/client/tokens.rb,
lib/trell/client/members.rb,
lib/trell/client/organizations.rb

Defined Under Namespace

Modules: Boards, Cards, Labels, Lists, Members, Organizations, Tokens

Constant Summary collapse

CONVENIENCE_HEADERS =
Set.new(%i(accept content_type))

Constants included from Configurable

Trell::Configurable::OPTIONS_KEYS

Instance Method Summary collapse

Methods included from Tokens

#tokens

Methods included from Labels

colors

Methods included from Lists

#create_list, #delete_list, #list, #lists, #update_list

Methods included from Cards

#card, #cards, #create_card, #delete_card, #update_card

Methods included from Boards

#board, #create_board, #delete_board, #member_boards, #organization_boards, #update_board

Methods included from Organizations

#create_organization, #delete_organization, #organization, #update_organization

Methods included from Members

#board_members, #member, #update_member

Methods included from Configurable

#configure, keys, #reset!

Methods included from Authentication

#application_authenticated?, #basic_authenticated?, #generation_endpoint, #key_generetor, #token_authenticated?, #token_generator, #user_authenticated?

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



26
27
28
29
30
# File 'lib/trell/client.rb', line 26

def initialize(options = {})
  Trell::Configurable.keys.each do |key|
    instance_variable_set(:"@#{key}", options[key] || Trell.instance_variable_get(:"@#{key}"))
  end
end

Instance Method Details

#agentObject



60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/trell/client.rb', line 60

def agent
  @agent ||= Sawyer::Agent.new(api_endpoint, sawyer_options) do |http|
    http.headers[:accept] = media_type
    http.headers[:content_type] = media_type
    http.headers[:user_agent] = user_agent

    if basic_authenticated?
      http.basic_auth(@login, @password)
    elsif token_authenticated?
      http.authorization 'token', @access_token
    end
  end
end

#delete(url, options = {}) ⇒ Object



52
53
54
# File 'lib/trell/client.rb', line 52

def delete(url, options = {})
  request :delete, url, options
end

#get(url, options = {}) ⇒ Object



36
37
38
# File 'lib/trell/client.rb', line 36

def get(url, options = {})
  request :get, url, parse_query_and_convenience_headers(options)
end

#head(url, options = {}) ⇒ Object



56
57
58
# File 'lib/trell/client.rb', line 56

def head(url, options = {})
  request :head, url, parse_query_and_convenience_headers(options)
end

#patch(url, options = {}) ⇒ Object



48
49
50
# File 'lib/trell/client.rb', line 48

def patch(url, options = {})
  request :patch, url, options
end

#post(url, options = {}) ⇒ Object



40
41
42
# File 'lib/trell/client.rb', line 40

def post(url, options = {})
  request :post, url, options
end

#put(url, options = {}) ⇒ Object



44
45
46
# File 'lib/trell/client.rb', line 44

def put(url, options = {})
  request :put, url, options
end

#same_options?(opts) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/trell/client.rb', line 32

def same_options?(opts)
  opts.hash == options.hash
end