Class: Walletkit::WalletKit
- Inherits:
-
Object
- Object
- Walletkit::WalletKit
- Defined in:
- lib/walletkit-ruby.rb
Overview
module Ruby
Instance Method Summary collapse
-
#create_pass(template_id, pass_data) ⇒ Object
Creates a pass.
-
#create_pass_template(template_data) ⇒ Object
Creates a pass template.
-
#delete_pass_template(template_id) ⇒ Object
Deletes a pass template.
-
#get_pass_template_info(template_id) ⇒ Object
Gets information about a pass template.
-
#get_pass_template_list ⇒ Object
Gets the list of all existing pass templates.
-
#initialize(api_key, brand_id) ⇒ WalletKit
constructor
Intializes REST client.
-
#update_pass(template_id, pass_data) ⇒ Object
Updates a pass.
Constructor Details
#initialize(api_key, brand_id) ⇒ WalletKit
Intializes REST client
-
Args :
-
api_key
-> the API key -
brand_id
-> the brand id
-
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/walletkit-ruby.rb', line 15 def initialize(api_key,brand_id) @api = 'api.walletkit.com' @api_key, @brand_id = api_key, brand_id @headers = { "api-key" => @api_key, "brand-id" => @brand_id, "Content-Type" => 'application/json' } @http = Net::HTTP.new(@api) end |
Instance Method Details
#create_pass(template_id, pass_data) ⇒ Object
Creates a pass
-
Args :
-
template_id
-> the pass template id -
pass_data
-> the pass data as a hash
-
-
Returns :
-
Json string containing information about the pass
-
85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/walletkit-ruby.rb', line 85 def create_pass(template_id, pass_data) begin request = Net::HTTP::Post.new('/v1/passes/' + template_id.to_s, @headers) request.body = pass_data.to_json response = @http.request(request) rescue Exception => e p e. p e.backtrace end response.body end |
#create_pass_template(template_data) ⇒ Object
Creates a pass template
-
Args :
-
template_data
-> the pass template data as a hash
-
-
Returns :
-
Json string containing the template id
-
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/walletkit-ruby.rb', line 33 def create_pass_template(template_data) begin request = Net::HTTP::Post.new('/v1/passes', @headers) request.body = template_data.to_json response = @http.request(request) rescue Exception => e p e. p e.backtrace end response.body end |
#delete_pass_template(template_id) ⇒ Object
Deletes a pass template
-
Args :
-
template_id
-> the pass template id
-
-
Returns :
-
Json string containing the server response
-
124 125 126 127 128 129 130 131 132 133 |
# File 'lib/walletkit-ruby.rb', line 124 def delete_pass_template(template_id) begin request = Net::HTTP::Delete.new('/v1/passes/' + template_id.to_s, @headers) response = @http.request(request) rescue Exception => e p e. p e.backtrace end response.body end |
#get_pass_template_info(template_id) ⇒ Object
Gets information about a pass template
-
Args :
-
template_id
-> the pass template id
-
-
Returns :
-
Json string containing information about the template
-
67 68 69 70 71 72 73 74 75 |
# File 'lib/walletkit-ruby.rb', line 67 def get_pass_template_info(template_id) begin response = @http.request_get('/v1/passes/' + template_id.to_s, @headers) rescue Exception => e p e. p e.backtrace end response.body end |
#get_pass_template_list ⇒ Object
Gets the list of all existing pass templates
-
Returns :
-
Json string containing id and description of templates
-
50 51 52 53 54 55 56 57 58 |
# File 'lib/walletkit-ruby.rb', line 50 def get_pass_template_list() begin response = @http.request_get('/v1/passes', @headers) rescue Exception => e p e. p e.backtrace end response.body end |
#update_pass(template_id, pass_data) ⇒ Object
Updates a pass
-
Args :
-
template_id
-> the pass template id -
pass_data
-> the pass data as a hash
-
-
Returns :
-
Json string containing information about the pass
-
105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/walletkit-ruby.rb', line 105 def update_pass(template_id, pass_data) begin request = Net::HTTP::Put.new('/v1/passes/' + template_id.to_s, @headers) request.body = pass_data.to_json response = @http.request(request) rescue Exception => e p e. p e.backtrace end response.body end |