Sha256: 4d2c5513033d0084f5e52f94e9f49cb5b16bb60440bd4cbc2ac03cf644b47aa7
Contents?: true
Size: 977 Bytes
Versions: 2
Compression:
Stored size: 977 Bytes
Contents
require 'json' module LinkShrink module Shrinkers # @author Jonah Ruiz <jonah@pixelhipsters.com> # Implements Google's URL Shortener API class Google < Base # Defines response structure to be parsed response_options do short_url 'id' end # Returns URL base for API # @return [String] api base url def base_url 'https://www.googleapis.com/urlshortener/v1/url' end # Returns URL query parameters # @return [String] query parameters to be used in request def api_query_parameter "?key=#{api_key}" end # Returns body parameters used in request header # @return [String] body parameters to be used in request header def body_parameters(new_url = nil) { 'longUrl' => url }.to_json end # Returns HTTP method to be used in request # @return [Symbol] post http method def http_method :post end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
link_shrink-0.0.8 | lib/link_shrink/shrinkers/google.rb |
link_shrink-0.0.7 | lib/link_shrink/shrinkers/google.rb |