Class: Karatekit::Client

Inherits:
Object
  • Object
show all
Includes:
Authentication, EventDetails, EventParts, Events, InstructorDetails, InstructorGroupMembers, InstructorGroups, Instructors, Locations, Posts, Products, RateLimit, Sessions, Configurable, Connection, Warnable
Defined in:
lib/karatekit/client.rb,
lib/karatekit/client/posts.rb,
lib/karatekit/client/events.rb,
lib/karatekit/client/products.rb,
lib/karatekit/client/sessions.rb,
lib/karatekit/client/locations.rb,
lib/karatekit/client/rate_limit.rb,
lib/karatekit/client/event_parts.rb,
lib/karatekit/client/instructors.rb,
lib/karatekit/client/event_details.rb,
lib/karatekit/client/instructor_groups.rb,
lib/karatekit/client/instructor_details.rb,
lib/karatekit/client/instructor_group_members.rb

Overview

Client for the kampfsport.center API

Defined Under Namespace

Modules: EventDetails, EventParts, Events, InstructorDetails, InstructorGroupMembers, InstructorGroups, Instructors, Locations, Posts, Products, RateLimit, Sessions

Constant Summary collapse

CONVENIENCE_HEADERS =

Header keys that can be passed in options hash to Karatekit::Connection#get,Karatekit::Connection#head

Set.new([:accept, :content_type])

Instance Attribute Summary

Attributes included from Configurable

#access_token, #api_endpoint, #auto_paginate, #connection_options, #default_media_type, #middleware, #per_page, #user_agent

Instance Method Summary collapse

Methods included from RateLimit

#rate_limit, #rate_limit!, #rate_limit_remaining, #rate_limit_remaining!

Methods included from InstructorGroupMembers

#instructor_group_member, #instructor_group_members

Methods included from InstructorGroups

#instructor_group, #instructor_groups

Methods included from InstructorDetails

#instructor_detail, #instructor_details

Methods included from Instructors

#instructor, #instructors

Methods included from Posts

#post, #posts

Methods included from EventParts

#event_part, #event_parts

Methods included from EventDetails

#event_detail, #event_details

Methods included from Events

#event, #events

Methods included from Sessions

#session, #sessions

Methods included from Products

#product, #products

Methods included from Locations

#location, #locations

Methods included from Warnable

#octokit_warn

Methods included from Connection

#agent, #delete, #get, #head, #last_response, #paginate, #patch, #post, #put, #root

Methods included from Authentication

#token_authenticated?

Methods included from Configurable

#configure, keys, #reset!, #same_options?

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



49
50
51
52
53
54
55
# File 'lib/karatekit/client.rb', line 49

def initialize(options = {})
  # Use options passed in, but fall back to module defaults
  Karatekit::Configurable.keys.each do |key|
    value = options.key?(key) ? options[key] : Karatekit.instance_variable_get(:"@#{key}")
    instance_variable_set(:"@#{key}", value)
  end
end

Instance Method Details

#access_token=(value) ⇒ Object

Set OAuth access token for authentication

Parameters:

  • value (String)

    40 character kampfsport.center OAuth access token



73
74
75
76
# File 'lib/karatekit/client.rb', line 73

def access_token=(value)
  reset_agent
  @access_token = value
end

#inspectString

Text representation of the client, masking tokens and passwords

Returns:

  • (String)


60
61
62
63
64
65
66
67
68
# File 'lib/karatekit/client.rb', line 60

def inspect
  inspected = super

  if @access_token
    inspected = inspected.gsub! @access_token, "#{'*'*36}#{@access_token[36..-1]}"
  end

  inspected
end