Class: Borneo::Client

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

Constant Summary collapse

@@should_mock_requests =
false

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client_id, client_secret, redirect_url, application_name = "Borneo Application", application_version = "0.0.1") ⇒ Client

Returns a new instance of Client.



26
27
28
29
30
31
32
33
# File 'lib/borneo/client.rb', line 26

def initialize(client_id, client_secret, redirect_url, application_name = "Borneo Application", application_version = "0.0.1")
  @client_id = client_id
  @client_secret = client_secret
  @redirect_url = redirect_url
  @google_client = nil
  @application_name = application_name
  @application_version = application_version
end

Instance Attribute Details

#application_nameObject (readonly)

Returns the value of attribute application_name.



7
8
9
# File 'lib/borneo/client.rb', line 7

def application_name
  @application_name
end

#application_versionObject (readonly)

Returns the value of attribute application_version.



7
8
9
# File 'lib/borneo/client.rb', line 7

def application_version
  @application_version
end

#client_idObject (readonly)

Returns the value of attribute client_id.



7
8
9
# File 'lib/borneo/client.rb', line 7

def client_id
  @client_id
end

#client_secretObject (readonly)

Returns the value of attribute client_secret.



7
8
9
# File 'lib/borneo/client.rb', line 7

def client_secret
  @client_secret
end

#redirect_urlObject (readonly)

Returns the value of attribute redirect_url.



7
8
9
# File 'lib/borneo/client.rb', line 7

def redirect_url
  @redirect_url
end

Class Method Details

.disable_mocking!Object



14
15
16
# File 'lib/borneo/client.rb', line 14

def self.disable_mocking!
  @@should_mock_requests = false
end

.enable_mocking!Object



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

def self.enable_mocking!
  @@should_mock_requests = true
  @@service_stubs = {}
end

.reset_mocks!Object



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

def self.reset_mocks!
  @@service_stubs = {}
end

.stub_service(service_name, service_version) ⇒ Object



22
23
24
# File 'lib/borneo/client.rb', line 22

def self.stub_service(service_name, service_version)
  @@service_stubs[[service_name, service_version]] ||= Borneo::Mock::Service.new(self, service_name, service_version)
end

Instance Method Details

#for(access_token, refresh_token) ⇒ Object



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

def for(access_token, refresh_token)
  google_client.authorization.clear_credentials!
  Borneo::AuthorizedProxy.new(self,access_token, refresh_token)
end

#google_clientObject



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

def google_client
  @google_client ||= Google::APIClient.new(:application_name => @application_name, :application_version => @application_version)
end

#mocking_requests?Boolean

Returns:

  • (Boolean)


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

def mocking_requests?
  !!@@should_mock_requests
end