Class: Trell::Client
- Inherits:
-
Object
- Object
- Trell::Client
- 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
- #agent ⇒ Object
- #delete(url, options = {}) ⇒ Object
- #get(url, options = {}) ⇒ Object
- #head(url, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #patch(url, options = {}) ⇒ Object
- #post(url, options = {}) ⇒ Object
- #put(url, options = {}) ⇒ Object
- #same_options?(opts) ⇒ Boolean
Methods included from Tokens
Methods included from Labels
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
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( = {}) Trell::Configurable.keys.each do |key| instance_variable_set(:"@#{key}", [key] || Trell.instance_variable_get(:"@#{key}")) end end |
Instance Method Details
#agent ⇒ Object
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, ) 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. 'token', @access_token end end end |
#delete(url, options = {}) ⇒ Object
52 53 54 |
# File 'lib/trell/client.rb', line 52 def delete(url, = {}) request :delete, url, end |
#get(url, options = {}) ⇒ Object
36 37 38 |
# File 'lib/trell/client.rb', line 36 def get(url, = {}) request :get, url, parse_query_and_convenience_headers() end |
#head(url, options = {}) ⇒ Object
56 57 58 |
# File 'lib/trell/client.rb', line 56 def head(url, = {}) request :head, url, parse_query_and_convenience_headers() end |
#patch(url, options = {}) ⇒ Object
48 49 50 |
# File 'lib/trell/client.rb', line 48 def patch(url, = {}) request :patch, url, end |
#post(url, options = {}) ⇒ Object
40 41 42 |
# File 'lib/trell/client.rb', line 40 def post(url, = {}) request :post, url, end |
#put(url, options = {}) ⇒ Object
44 45 46 |
# File 'lib/trell/client.rb', line 44 def put(url, = {}) request :put, url, end |
#same_options?(opts) ⇒ Boolean
32 33 34 |
# File 'lib/trell/client.rb', line 32 def (opts) opts.hash == .hash end |