passdock 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (6) hide show
  1. data/Manifest +4 -0
  2. data/README.md +80 -0
  3. data/Rakefile +14 -0
  4. data/lib/passdock.rb +89 -0
  5. data/passdock.gemspec +29 -0
  6. metadata +57 -0
@@ -0,0 +1,4 @@
1
+ Manifest
2
+ README.md
3
+ Rakefile
4
+ lib/passdock.rb
@@ -0,0 +1,80 @@
1
+ passdock-ruby
2
+ =============
3
+
4
+ Sample code to interact with Passdock API in ruby.
5
+
6
+ ### Dependancies
7
+
8
+ This sample code requires *httparty*.
9
+
10
+ Use
11
+
12
+ gem install httparty
13
+
14
+ to istall them.
15
+
16
+ ### Get your authentication token
17
+
18
+ You need to register on [api.passdock.com](https://api.passdock.com) and get an [api token](https://api.passdock.com/settings).
19
+
20
+ ### Let's start
21
+
22
+ Once obtained you can create a new istance of the Passdock object.
23
+
24
+ passdock = Passdock.new("YOUR_TOKEN")
25
+
26
+ Then you can call some methods to get the desired informations out of Passdock or to create new Passes.
27
+
28
+ All the replies are JSON formatted text files.
29
+
30
+ To get started just add one of the following line, appropriately modified at the bottom of the *passdock.rb* file.
31
+
32
+ #### Get Templates
33
+
34
+ Get all your templates for your account
35
+
36
+ pp passdock.templates
37
+
38
+ #### Get a Template
39
+
40
+ Pass the id of the template as argument
41
+
42
+ pp passdock.template(82)
43
+
44
+ #### Destroy a Template
45
+
46
+ The first argument is the template id, the second one if you want exanded errors.
47
+
48
+ pp passdock.destroy_template(82, true)
49
+
50
+ #### Get a Pass
51
+
52
+ The first parameter is the Pass ID, the second its template ID
53
+
54
+ pp passdock.pass(132, 82)
55
+
56
+ #### Create a Pass
57
+
58
+ The first argument is the a JSON jash containing the Pass structure, more informations on [api.passdock.com/doc](https://api.passdock.com/doc).
59
+ The second argument is the template id, the third one if you want debug informations and the last one exanded errors.
60
+
61
+ pp passdock.create_pass('{"serial_number":"1234", "gate":"12"}', 82, true, false)
62
+
63
+ #### Update a Pass
64
+
65
+ The first argument is the a JSON jash containing the Pass structure, more informations on [api.passdock.com/doc](https://api.passdock.com/doc).
66
+ The second argument is the template id, the third one if you want debug informations and the last one exanded errors.
67
+
68
+ pp passdock.update_pass('{"serial_number":"5678", "gate":"15"}', 94, 82, true, false)
69
+
70
+ #### Download a Pass
71
+
72
+ The first parameter is the Pass ID, the second its template ID
73
+
74
+ pp passdock.download_pass(82, 82)
75
+
76
+ #### Destroy a Pass
77
+
78
+ The first argument is the template id, the second one if you want exanded errors.
79
+
80
+ pp passdock.destroy_pass(94, 82, true)
@@ -0,0 +1,14 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'echoe'
4
+
5
+ Echoe.new('passdock', '0.1.5') do |p|
6
+ p.description = "Talk with Passdock API"
7
+ p.url = "http://github.com/Creapptor/passdock-ruby"
8
+ p.author = "Creapptor S.A."
9
+ p.email = "info@creapptor.com"
10
+ p.ignore_pattern = ["tmp/*", "script/*"]
11
+ p.development_dependencies = []
12
+ end
13
+
14
+ Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
@@ -0,0 +1,89 @@
1
+ gem 'httparty'
2
+
3
+ module Passdock
4
+ include HTTParty
5
+ @@api_base = 'https://api.passdock.com/api/v1/'
6
+ @@api_key = nil
7
+
8
+ def self.api_key=(api_key)
9
+ @@api_key = api_key
10
+ end
11
+
12
+ def self.api_key
13
+ @@api_key
14
+ end
15
+
16
+ def self.api_base=(api_base)
17
+ @@api_base = api_base
18
+ end
19
+
20
+ def self.api_base
21
+ @@api_base
22
+ end
23
+
24
+ def self.templates
25
+ self.get("#{@@api_base}/templates?api_token=#{@@api_key}")
26
+ end
27
+
28
+ def self.template(id)
29
+ self.get("#{@@api_base}/templates/#{id}?api_token=#{@@api_key}")
30
+ end
31
+
32
+ def self.destroy_template(family_id, errors)
33
+ _errors = errors ? "true" : "false"
34
+ options = {
35
+ :body => {
36
+ :errors => _errors,
37
+ :api_token => @@api_key
38
+ }
39
+ }
40
+ self.delete("#{@@api_base}/templates/#{family_id}", options)
41
+ end
42
+
43
+ def self.pass(pass_id, family_id)
44
+ self.get("#{@@api_base}/templates/#{family_id}/passes/#{pass_id}?api_token=#{@@api_key}")
45
+ end
46
+
47
+ def self.download_pass(pass_id, family_id)
48
+ self.get("#{@@api_base}/templates/#{family_id}/passes/#{pass_id}?api_token=#{@@api_key}&show=true")
49
+ end
50
+
51
+ def self.create_pass(pass, family_id, debug, errors)
52
+ _debug = debug ? "true" : "false"
53
+ _errors = errors ? "true" : "false"
54
+ options = {
55
+ :body => {
56
+ :debug => _debug,
57
+ :errors => _errors,
58
+ :api_token => @@api_key,
59
+ :pass => pass
60
+ }
61
+ }
62
+ self.post("#{@@api_base}/templates/#{family_id}/passes", options)
63
+ end
64
+
65
+ def self.update_pass(pass, pass_id, family_id, debug, errors)
66
+ _debug = debug ? "true" : "false"
67
+ _errors = errors ? "true" : "false"
68
+ options = {
69
+ :body => {
70
+ :debug => _debug,
71
+ :errors => _errors,
72
+ :api_token => @@api_key,
73
+ :pass => pass
74
+ }
75
+ }
76
+ self.put("#{@@api_base}/templates/#{family_id}/passes/#{pass_id}", options)
77
+ end
78
+
79
+ def self.destroy_pass(pass_id, family_id, errors)
80
+ _errors = errors ? "true" : "false"
81
+ options = {
82
+ :body => {
83
+ :errors => _errors,
84
+ :api_token => @@api_key
85
+ }
86
+ }
87
+ self.delete("#{@@api_base}/templates/#{family_id}/passes/#{pass_id}", options)
88
+ end
89
+ end
@@ -0,0 +1,29 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "passdock"
5
+ s.version = "0.1.5"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Creapptor S.A."]
9
+ s.date = "2012-09-19"
10
+ s.description = "Talk with Passdock API"
11
+ s.email = "info@creapptor.com"
12
+ s.extra_rdoc_files = ["README.md", "lib/passdock.rb"]
13
+ s.files = ["Manifest", "README.md", "Rakefile", "lib/passdock.rb", "passdock.gemspec"]
14
+ s.homepage = "http://github.com/Creapptor/passdock-ruby"
15
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Passdock", "--main", "README.md"]
16
+ s.require_paths = ["lib"]
17
+ s.rubyforge_project = "passdock"
18
+ s.rubygems_version = "1.8.24"
19
+ s.summary = "Talk with Passdock API"
20
+
21
+ if s.respond_to? :specification_version then
22
+ s.specification_version = 3
23
+
24
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
25
+ else
26
+ end
27
+ else
28
+ end
29
+ end
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: passdock
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.5
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Creapptor S.A.
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-19 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Talk with Passdock API
15
+ email: info@creapptor.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files:
19
+ - README.md
20
+ - lib/passdock.rb
21
+ files:
22
+ - Manifest
23
+ - README.md
24
+ - Rakefile
25
+ - lib/passdock.rb
26
+ - passdock.gemspec
27
+ homepage: http://github.com/Creapptor/passdock-ruby
28
+ licenses: []
29
+ post_install_message:
30
+ rdoc_options:
31
+ - --line-numbers
32
+ - --inline-source
33
+ - --title
34
+ - Passdock
35
+ - --main
36
+ - README.md
37
+ require_paths:
38
+ - lib
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ none: false
47
+ requirements:
48
+ - - ! '>='
49
+ - !ruby/object:Gem::Version
50
+ version: '1.2'
51
+ requirements: []
52
+ rubyforge_project: passdock
53
+ rubygems_version: 1.8.24
54
+ signing_key:
55
+ specification_version: 3
56
+ summary: Talk with Passdock API
57
+ test_files: []