doattend 0.0.4 → 0.1.0
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.
- checksums.yaml +4 -4
- data/README.md +35 -2
- data/lib/doattend.rb +0 -8
- data/lib/doattend/base.rb +31 -4
- data/lib/doattend/ticket.rb +23 -0
- data/lib/doattend/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b430ff4f45048ed5826060285b2558271d07d9f6
|
4
|
+
data.tar.gz: 6162cf7b437b8037da812bff7b464efbb5fc96f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c6c0b675729091b1ca9453f940776eafb6fb95238050d6c33c6c1d095ec3a0cde6590028be48cf463927bd0107315b0f294622995db8c837fd08a107ddaa77f
|
7
|
+
data.tar.gz: fe830af5b2b57cce2eb87a8be8262894afd27507c83f517547f53e0b116011bb056313c3233e1cdf550d9fc0bace62052cf0dda87d523c85246dac9a606297fe
|
data/README.md
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# DoAttend
|
2
2
|
|
3
|
-
|
3
|
+
[](http://badge.fury.io/rb/doattend)
|
4
|
+
[](https://codeclimate.com/github/swaroopsm/doattend)
|
5
|
+
|
6
|
+
Rails generator and functions to communicate the DoAttend API. You need to have a DoAttend API key to communicate the DoAttend API. If you do not have one yet, you can contact DoAttend to get an API key.
|
4
7
|
|
5
8
|
## Installation
|
6
9
|
|
@@ -18,7 +21,37 @@ Or install it yourself as:
|
|
18
21
|
|
19
22
|
## Usage
|
20
23
|
|
21
|
-
|
24
|
+
Doattend provides a rails generator that gets you started quikly.
|
25
|
+
Run the following generator to generate config/doattend.yml
|
26
|
+
|
27
|
+
$ rails g doattend:install -e YOUR_DOATTEND_EVENT_ID -k YOUR_DOATTEND_API_KEY
|
28
|
+
|
29
|
+
If you are not using Rails you can use require to include it:
|
30
|
+
$ require "doattend"
|
31
|
+
|
32
|
+
## Getting Started
|
33
|
+
Rails Way:
|
34
|
+
@doattend = Doattend::Base.new # This loads the key and event that was generated from config/doattend.yml
|
35
|
+
|
36
|
+
Non-Rails Way:
|
37
|
+
@doattend = Doattend::Base.new('YOUR_DOATTEND_EVENT_ID', 'YOUR_DOATTEND_API_KEY')
|
38
|
+
|
39
|
+
|
40
|
+
## Methods
|
41
|
+
#### Fetch all data from DoAttend
|
42
|
+
@doattend.fetch
|
43
|
+
|
44
|
+
#### Get total tickets
|
45
|
+
@doattend.aggregate
|
46
|
+
|
47
|
+
#### Get ticket names/types used in an event
|
48
|
+
@doattend.ticket.names
|
49
|
+
|
50
|
+
#### Get total number of registrations for a ticket name/type
|
51
|
+
@doattend.ticket.aggregate('ticket_type')
|
52
|
+
|
53
|
+
Eg.:
|
54
|
+
@doattend.ticket.aggregate(@doattend.ticket.names.first)
|
22
55
|
|
23
56
|
## Contributing
|
24
57
|
|
data/lib/doattend.rb
CHANGED
data/lib/doattend/base.rb
CHANGED
@@ -1,19 +1,46 @@
|
|
1
1
|
require "rest-client"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
require_relative "ticket.rb"
|
2
5
|
|
3
6
|
module Doattend
|
4
7
|
|
5
8
|
class Base
|
6
9
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
+
attr_accessor :event, :key, :result
|
11
|
+
|
12
|
+
def initialize(e=nil, k=nil)
|
13
|
+
if defined? Rails
|
14
|
+
conf = YAML.load_file("#{Rails.root}/config/doattend.yml")
|
15
|
+
self.event = conf['doattend']['event']
|
16
|
+
self.key = conf['doattend']['key']
|
17
|
+
else
|
18
|
+
self.event = e
|
19
|
+
self.key = k
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
# Request DoAttend and fetch results.
|
25
|
+
def fetch
|
26
|
+
url = "http://doattend.com/api/events/#{self.event}/participants_list.json?api_key=#{self.key}"
|
10
27
|
begin
|
11
|
-
RestClient.get(url)
|
28
|
+
self.result = JSON.parse(RestClient.get(url))
|
12
29
|
rescue Exception => e
|
13
30
|
e
|
14
31
|
end
|
15
32
|
end
|
16
33
|
|
34
|
+
# Get Total Participants.
|
35
|
+
def aggregate
|
36
|
+
self.result['participants'].size
|
37
|
+
end
|
38
|
+
|
39
|
+
# Use methods of Ticket class.
|
40
|
+
def ticket
|
41
|
+
Doattend::Ticket.new(self.result['participants'])
|
42
|
+
end
|
43
|
+
|
17
44
|
end
|
18
45
|
|
19
46
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Doattend
|
2
|
+
|
3
|
+
class Ticket
|
4
|
+
|
5
|
+
attr_accessor :result
|
6
|
+
|
7
|
+
def initialize(result)
|
8
|
+
self.result = result
|
9
|
+
end
|
10
|
+
|
11
|
+
# Returns different ticket names that is available for the event.
|
12
|
+
def names
|
13
|
+
self.result.map{ |t| t['Ticket_Name'] }.uniq
|
14
|
+
end
|
15
|
+
|
16
|
+
# Returns number of registrations for a ticket type
|
17
|
+
def aggregate(name)
|
18
|
+
self.result.count{ |t| t['Ticket_Name'] == name }
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
data/lib/doattend/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: doattend
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Swaroop SM
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: json
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - '>='
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- README.md
|
91
91
|
- Gemfile
|
92
92
|
- Rakefile
|
93
|
+
- lib/doattend/ticket.rb
|
93
94
|
- lib/doattend/version.rb
|
94
95
|
- lib/doattend/base.rb
|
95
96
|
- lib/generators/doattend/install/USAGE
|