Class: LinkShrink::Shrinkers::Google
- Defined in:
- lib/link_shrink/shrinkers/google.rb
Overview
Implements Google’s URL Shortener API
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#api_query_parameter ⇒ String
Returns URL query parameters.
-
#base_url ⇒ String
Returns URL base for API.
-
#body_parameters(new_url = nil) ⇒ String
Returns body parameters used in request header.
-
#http_method ⇒ Symbol
Returns HTTP method to be used in request.
Methods inherited from Base
#api_key, #api_key?, #api_url, collection, #content_type, error, #generate_chart_url, inherited, response_options, #sanitize_url, short_url
Instance Method Details
#api_query_parameter ⇒ String
Returns URL query parameters
21 22 23 |
# File 'lib/link_shrink/shrinkers/google.rb', line 21 def api_query_parameter "?key=#{api_key}" end |
#base_url ⇒ String
Returns URL base for API
15 16 17 |
# File 'lib/link_shrink/shrinkers/google.rb', line 15 def base_url 'https://www.googleapis.com/urlshortener/v1/url' end |
#body_parameters(new_url = nil) ⇒ String
Returns body parameters used in request header
27 28 29 |
# File 'lib/link_shrink/shrinkers/google.rb', line 27 def body_parameters(new_url = nil) { 'longUrl' => url }.to_json end |
#http_method ⇒ Symbol
Returns HTTP method to be used in request
33 34 35 |
# File 'lib/link_shrink/shrinkers/google.rb', line 33 def http_method :post end |