lib/notifications/client/speaker.rb in notifications-ruby-client-2.0.0 vs lib/notifications/client/speaker.rb in notifications-ruby-client-2.1.0
- old
+ new
@@ -58,9 +58,38 @@
path << "?" << URI.encode_www_form(options) if options.any?
request = Net::HTTP::Get.new(path, headers)
perform_request!(request)
end
+ ##
+ # @param url path of endpoint
+ # @param id [String]
+ # @param options [Hash] query
+ # @see #perform_request!
+ def get_with_url(url, options = {})
+ path = url
+ path << "?" << URI.encode_www_form(options) if options.any?
+ request = Net::HTTP::Get.new(path, headers)
+ perform_request!(request)
+ end
+
+ ##
+ # @param url [String] path of the endpoint
+ # @param form_data [Hash]
+ # @option form_data [String] :template_id
+ # id of the template to render
+ # @option form_data [Hash] :personalisation
+ # fields to use in the template
+ # @see #perform_request!
+ def post_with_url(url, form_data)
+ request = Net::HTTP::Post.new(
+ url,
+ headers
+ )
+ request.body = form_data.is_a?(Hash) ? form_data.to_json : form_data
+ perform_request!(request)
+ end
+
private
##
# @return [Hash] JSON parsed response
# @raise [RequestError] if request is