Class: Awesm::Url
- Inherits:
-
Hashie::Mash
- Object
- Hashie::Mash
- Awesm::Url
- Defined in:
- lib/awesm/url.rb
Constant Summary collapse
- PATH =
'/url'
- REQUIRED_SHARE_PARAMS =
[:url, :key, :tool, :channel, :destination].freeze
Class Method Summary collapse
-
.create(params = {}) ⇒ Object
Right now this method only supports the json format.
- .share(params = {}) ⇒ Object
-
.static(params = {}) ⇒ Object
Right now this method only supports the json format.
Class Method Details
.create(params = {}) ⇒ Object
Right now this method only supports the json format
7 8 9 |
# File 'lib/awesm/url.rb', line 7 def self.create(params = {}) call_api("#{Awesm::HOST}#{PATH}.json", params) end |
.share(params = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/awesm/url.rb', line 11 def self.share(params = {}) if required_params_present?(REQUIRED_SHARE_PARAMS, params) = params.clone = .delete_if{|key,value| REQUIRED_SHARE_PARAMS.include?(key) } query = .map{|k,v| "#{k}=#{v}"}.join('&') share_url = "#{Awesm::HOST}#{PATH}/share?v=3&url=#{params[:url]}&key=#{params[:key]}&tool=#{params[:tool]}&channel=#{params[:channel]}&destination=#{params[:destination]}" share_url += "&#{query}" if query.length > 0 share_url end end |