Class: GoogleShortLinks::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/google_short_links/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



16
17
18
19
20
# File 'lib/google_short_links/client.rb', line 16

def initialize options={}
  self.server = options[:server]
  self.secret = options[:secret]
  self.email = options[:email]
end

Instance Attribute Details

#emailObject

Returns the value of attribute email.



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

def email
  @email
end

#secretObject

Returns the value of attribute secret.



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

def secret
  @secret
end

#serverObject

Returns the value of attribute server.



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

def server
  @server
end

Instance Method Details

#get_details(shortcut, params = {}) ⇒ Object



54
55
56
# File 'lib/google_short_links/client.rb', line 54

def get_details shortcut, params={}
  self.class.get(get_details_url(shortcut, params)).parsed_response
end

#get_details_url(shortcut, params = {}) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/google_short_links/client.rb', line 38

def get_details_url shortcut, params={}
  request_path = request_path(:get_details)

  query = params_to_query(base_params.merge(:shortcut => shortcut).merge(params))

  digest_url(request_path, query)
end

#get_or_create_hash(url, params = {}) ⇒ Object



46
47
48
# File 'lib/google_short_links/client.rb', line 46

def get_or_create_hash url, params={}
  self.class.get(get_or_create_hash_url(url, params)).parsed_response
end

#get_or_create_hash_url(url, params = {}) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/google_short_links/client.rb', line 22

def get_or_create_hash_url url, params={}
  request_path = request_path(:get_or_create_hash)

  query = params_to_query(base_params.merge(:url => url).merge(params))

  digest_url(request_path, query)
end


50
51
52
# File 'lib/google_short_links/client.rb', line 50

def get_or_create_shortlink url, shortcut, params={}
  self.class.get(get_or_create_shortlink_url(url, shortcut, params)).parsed_response
end


30
31
32
33
34
35
36
# File 'lib/google_short_links/client.rb', line 30

def get_or_create_shortlink_url url, shortcut, params={}
  request_path = request_path(:get_or_create_shortlink)

  query = params_to_query(base_params.merge(:url => url, :shortcut => shortcut).merge(params))

  digest_url(request_path, query)
end