Class: MdNotes::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/md_notes/client.rb

Overview

md_notes client class.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(timeout: 60, max_retries: 0, retry_interval: 1, backoff_factor: 2, retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524], retry_methods: %i[get put],, environment: Environment::PRODUCTION, o_auth_client_id: 'TODO: Replace', o_auth_client_secret: 'TODO: Replace', o_auth_username: 'TODO: Replace', o_auth_password: 'TODO: Replace', o_auth_token: nil, config: nil) ⇒ Client

Returns a new instance of Client.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/md_notes/client.rb', line 34

def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
               backoff_factor: 2,
               retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
               retry_methods: %i[get put],
               environment: Environment::PRODUCTION,
               o_auth_client_id: 'TODO: Replace',
               o_auth_client_secret: 'TODO: Replace',
               o_auth_username: 'TODO: Replace',
               o_auth_password: 'TODO: Replace', o_auth_token: nil,
               config: nil)
  @config = if config.nil?
              Configuration.new(timeout: timeout, max_retries: max_retries,
                                retry_interval: retry_interval,
                                backoff_factor: backoff_factor,
                                retry_statuses: retry_statuses,
                                retry_methods: retry_methods,
                                environment: environment,
                                o_auth_client_id: o_auth_client_id,
                                o_auth_client_secret: o_auth_client_secret,
                                o_auth_username: o_auth_username,
                                o_auth_password: o_auth_password,
                                o_auth_token: o_auth_token)
            else
              config
            end
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



9
10
11
# File 'lib/md_notes/client.rb', line 9

def config
  @config
end

Instance Method Details

#authObject

Returns the authentication class for easy access.



12
13
14
# File 'lib/md_notes/client.rb', line 12

def auth
  OAuth2
end

#o_auth_authorizationOAuthAuthorizationController

Access to o_auth_authorization controller.

Returns:



30
31
32
# File 'lib/md_notes/client.rb', line 30

def o_auth_authorization
  @o_auth_authorization ||= OAuthAuthorizationController.new config
end

#serviceServiceController

Access to service controller.

Returns:



18
19
20
# File 'lib/md_notes/client.rb', line 18

def service
  @service ||= ServiceController.new config
end

#userUserController

Access to user controller.

Returns:



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

def user
  @user ||= UserController.new config
end