Class: PassNinja::PassTemplates
- Inherits:
-
Object
- Object
- PassNinja::PassTemplates
- Defined in:
- lib/passninja.rb
Instance Method Summary collapse
- #find(pass_template_key) ⇒ Object
-
#initialize(account_id, api_key, host, use_ssl) ⇒ PassTemplates
constructor
A new instance of PassTemplates.
Constructor Details
#initialize(account_id, api_key, host, use_ssl) ⇒ PassTemplates
Returns a new instance of PassTemplates.
28 29 30 31 32 33 |
# File 'lib/passninja.rb', line 28 def initialize(account_id, api_key, host, use_ssl) @account_id = account_id @api_key = api_key @host = host @use_ssl = use_ssl end |
Instance Method Details
#find(pass_template_key) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/passninja.rb', line 35 def find(pass_template_key) uri = URI("#{@host}/v1/pass_templates/#{pass_template_key}") puts uri request = Net::HTTP::Get.new(uri) request["X-API-KEY"] = @api_key request["X-ACCOUNT-ID"] = @account_id response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: @use_ssl) do |http| http.request(request) end begin JSON.parse(response.body) rescue JSON::ParserError { error: "Unable to parse response" } end end |