Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added Widget tag creator and bumped version.

  • Loading branch information...
commit d9314d454823244645b4338a4d1f9504be8fb9ed 1 parent 4172ea0
@joost joost authored
View
8 README.md
@@ -46,6 +46,14 @@ Because sometimes multiple places have the same phone number we can do more spec
:phone => place.phone_number # Eg. '010-12341234'.
)
+## Widget usage
+
+ RefreshingmenusApi::Widget.tag(:place_id => 'some_place_id', :widget_token => 'some_token')
+
+This will result in a script tag like:
+
+ <script id='rm-menuwidget' src='http://www.refreshingmenus.com/api/v1/widget.js?dom_id=rm-menuwidget&place_id=some_place_id&widget_token=some_token'></script>"
+
## Contributing
1. Fork it
View
4 lib/refreshingmenus_api.rb
@@ -1,4 +1,5 @@
require 'refreshingmenus_api/version'
+require 'refreshingmenus_api/widget'
require 'httparty'
require 'active_support/core_ext'
@@ -28,6 +29,9 @@ class Client
attr_reader :auth_token, :version, :format
+ # Options:
+ # * :auth_token - Your RefreshingMenus Authentication token (API)
+ # * :version - Version (defaults to 1)
def initialize(options = {})
@auth_token = options[:auth_token]
@version = options[:version] || '1'
View
2  lib/refreshingmenus_api/version.rb
@@ -1,3 +1,3 @@
module RefreshingmenusApi
- VERSION = "0.0.2"
+ VERSION = "0.0.3"
end
View
21 lib/refreshingmenus_api/widget.rb
@@ -0,0 +1,21 @@
+module RefreshingmenusApi
+ class Widget
+
+ # Options:
+ # * widget_token (required) - Your RefreshingMenus Widget token
+ # * place_id (required) - The RefreshingMenus Place ID (UUID)
+ # * secure - Boolean, we'll use https if true
+ # * style - The style name we should use (default: 'default'), use 'none' for no styling (if you embed your own styling)
+ def self.tag(options)
+ raise ArgumentError, "Expected options argument to be a Hash, got #{options.inspect}." if not options.is_a?(Hash)
+ options[:dom_id] = 'rm-menuwidget'
+ raise ArgumentError, "Expected a :place_id as option but got #{options[:place_id].inspect}." if not options[:place_id].is_a?(String)
+ raise ArgumentError, "Expected a :widget_token as option but got #{options[:widget_token].inspect}." if not options[:widget_token].is_a?(String)
+ secure = options.delete(:secure)
+ version = options.delete(:version) || '1'
+ src = "#{secure ? 'https' : 'http'}://www.refreshingmenus.com/api/v#{version}/widget.js?#{options.to_param}"
+ return "<script id='#{options[:dom_id]}' src='#{src}'></script>"
+ end
+
+ end
+end

0 comments on commit d9314d4

Please sign in to comment.
Something went wrong with that request. Please try again.