Class: GoogleShortLinks::Client
- Inherits:
-
Object
- Object
- GoogleShortLinks::Client
- Includes:
- HTTParty
- Defined in:
- lib/google_short_links/client.rb
Instance Attribute Summary collapse
-
#email ⇒ Object
Returns the value of attribute email.
-
#secret ⇒ Object
Returns the value of attribute secret.
-
#server ⇒ Object
Returns the value of attribute server.
Instance Method Summary collapse
- #get_details(shortcut, params = {}) ⇒ Object
- #get_details_url(shortcut, params = {}) ⇒ Object
- #get_or_create_hash(url, params = {}) ⇒ Object
- #get_or_create_hash_url(url, params = {}) ⇒ Object
- #get_or_create_shortlink(url, shortcut, params = {}) ⇒ Object
- #get_or_create_shortlink_url(url, shortcut, params = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
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 ={} self.server = [:server] self.secret = [:secret] self.email = [:email] end |
Instance Attribute Details
#email ⇒ Object
Returns the value of attribute email.
12 13 14 |
# File 'lib/google_short_links/client.rb', line 12 def email @email end |
#secret ⇒ Object
Returns the value of attribute secret.
12 13 14 |
# File 'lib/google_short_links/client.rb', line 12 def secret @secret end |
#server ⇒ Object
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 |
#get_or_create_shortlink(url, shortcut, params = {}) ⇒ Object
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 |
#get_or_create_shortlink_url(url, shortcut, params = {}) ⇒ Object
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 |