organizer 0.0.3 → 0.0.4
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/lib/organizer.rb +13 -13
- data/lib/organizer/objects/event.rb +42 -0
- data/lib/organizer/objects/ticket.rb +23 -0
- data/lib/organizer/request.rb +6 -4
- data/lib/organizer/response.rb +6 -3
- metadata +4 -3
- data/lib/organizer/event.rb +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34c7dc76ab5035ff50d5b8d21e733f0e39d889a7
|
4
|
+
data.tar.gz: 8005cebf0d7145d67f3546c8cb5990885ca6d6d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 452721e3a826b85f20d848f5f4f8ecc32d34ae8458a3c71e5b2016aff489b746017fdbbec13afc346c0f1f9dc10af9ce7c5d90b1137230218bdb9dde082dcc22
|
7
|
+
data.tar.gz: e0e6f9b89d7b196e1776602b18656f5e9dbb86d4e183e51e35d806032471004a6df2419e087228bb1d8f91380396259885d7af009a9f4a5b581a903be6a9358d
|
data/lib/organizer.rb
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
require "faraday"
|
2
|
+
Dir[File.dirname(__FILE__) + '/organizer/objects/*.rb'].each do |file|
|
3
|
+
require file
|
4
|
+
end
|
2
5
|
Dir[File.dirname(__FILE__) + '/organizer/*.rb'].each do |file|
|
3
6
|
require file
|
4
7
|
end
|
5
8
|
|
6
9
|
module Organizer
|
7
|
-
|
8
|
-
|
9
|
-
params = args[0].is_a?(Hash) ? args[0] : {}
|
10
|
+
def Organizer.method_missing(method, *args)
|
11
|
+
params = args[0].is_a?(Hash) ? args[0] : {}
|
10
12
|
|
11
|
-
|
12
|
-
path = "#{method}/"
|
13
|
+
path = "#{method}/"
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
if params[:id]
|
16
|
+
path = path + "#{params.delete(:id)}/"
|
17
|
+
end
|
17
18
|
|
18
|
-
|
19
|
-
|
19
|
+
Request.new(path, params)
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
end
|
22
|
+
class APIException < ::Exception; end
|
23
|
+
class MissingIdException < APIException; end
|
24
24
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Organizer
|
2
|
+
class Event
|
3
|
+
attr_reader :name, :description, :start, :end, :online_event, :currency, :listed
|
4
|
+
attr_writer :online_event, :currency, :listed, :status
|
5
|
+
|
6
|
+
def initialize(params={})
|
7
|
+
params.each do |attr, value|
|
8
|
+
self.public_send("#{attr}=", value)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def name=(arg)
|
13
|
+
raise "Expecting a String, got: #{arg.inspect}" unless arg.kind_of?(String)
|
14
|
+
@name = {
|
15
|
+
html: arg
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
def description=(arg)
|
20
|
+
raise "Expecting a String, got: #{arg.inspect}" unless arg.kind_of?(String)
|
21
|
+
@description = {
|
22
|
+
html: arg
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
def start=(arg)
|
27
|
+
raise "Expecting a Time, got: #{arg.inspect}" unless arg.kind_of?(Time)
|
28
|
+
@start = {
|
29
|
+
timezone: Time.zone.tzinfo.name,
|
30
|
+
utc: arg.utc.iso8601
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
def end=(arg)
|
35
|
+
raise "Expecting a Time, got: #{arg.inspect}" unless arg.kind_of?(Time)
|
36
|
+
@end = {
|
37
|
+
timezone: Time.zone.tzinfo.name,
|
38
|
+
utc: arg.utc.iso8601
|
39
|
+
}
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Organizer
|
2
|
+
class Ticket
|
3
|
+
attr_reader :cost, :sales_start
|
4
|
+
attr_accessor :name, :description, :free, :quantity_total,
|
5
|
+
:donation, :sales_start
|
6
|
+
|
7
|
+
def initialize(params={})
|
8
|
+
params.each do |attr, value|
|
9
|
+
self.public_send("#{attr}=", value)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def cost= (arg)
|
14
|
+
raise "Expecting a Hash, got: #{arg.inspect}" unless arg.kind_of?(Hash)
|
15
|
+
@cost = arg
|
16
|
+
end
|
17
|
+
|
18
|
+
def sales_start=(arg)
|
19
|
+
raise "Expecting a Time, got: #{arg.inspect}" unless arg.kind_of?(Time)
|
20
|
+
@sales_start = arg.utc.iso8601
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/organizer/request.rb
CHANGED
@@ -8,28 +8,30 @@ module Organizer
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def get
|
11
|
-
response = api.get(path, query)
|
11
|
+
response = api.get(path, query)
|
12
12
|
Response.new(response)
|
13
13
|
end
|
14
14
|
|
15
15
|
def post
|
16
|
-
api.post do |req|
|
16
|
+
response = api.post do |req|
|
17
17
|
req.url path
|
18
18
|
req.headers['Content-Type'] = 'application/json'
|
19
19
|
req.body = query.to_json
|
20
20
|
end
|
21
|
+
Response.new(response)
|
21
22
|
end
|
22
23
|
|
23
24
|
def put
|
24
|
-
api.put do |req|
|
25
|
+
response = api.put do |req|
|
25
26
|
req.url path
|
26
27
|
req.headers['Content-Type'] = 'application/json'
|
27
28
|
req.body = query.to_json
|
28
29
|
end
|
30
|
+
Response.new(response)
|
29
31
|
end
|
30
32
|
|
31
33
|
def delete
|
32
|
-
response = api.delete(path, query)
|
34
|
+
response = api.delete(path, query)
|
33
35
|
Response.new(response)
|
34
36
|
end
|
35
37
|
|
data/lib/organizer/response.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
module Organizer
|
2
2
|
class Response
|
3
|
-
attr_accessor :body
|
3
|
+
attr_accessor :body, :status, :method, :url
|
4
4
|
|
5
|
-
def initialize(
|
6
|
-
|
5
|
+
def initialize(data)
|
6
|
+
@body = JSON.parse(data.env.body)
|
7
|
+
@url = data.env.url
|
8
|
+
@method = data.env.method
|
9
|
+
@status = data.env.status
|
7
10
|
end
|
8
11
|
end
|
9
12
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: organizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Imran Ismail
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -49,7 +49,8 @@ files:
|
|
49
49
|
- Rakefile
|
50
50
|
- lib/organizer.rb
|
51
51
|
- lib/organizer/config.rb
|
52
|
-
- lib/organizer/event.rb
|
52
|
+
- lib/organizer/objects/event.rb
|
53
|
+
- lib/organizer/objects/ticket.rb
|
53
54
|
- lib/organizer/request.rb
|
54
55
|
- lib/organizer/response.rb
|
55
56
|
- lib/tasks/organizer_tasks.rake
|
data/lib/organizer/event.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
module Organizer
|
2
|
-
class Event
|
3
|
-
attr_accessor :name, :description, :start, :end, :online_event, :hash
|
4
|
-
|
5
|
-
def initialize(params={})
|
6
|
-
params.each do |attr, value|
|
7
|
-
self.public_send("#{attr}=", value)
|
8
|
-
end
|
9
|
-
|
10
|
-
self.hash =
|
11
|
-
{
|
12
|
-
name: {
|
13
|
-
html: self.name
|
14
|
-
},
|
15
|
-
description: {
|
16
|
-
html: self.description
|
17
|
-
},
|
18
|
-
start: {
|
19
|
-
timezone: Time.zone.tzinfo.name,
|
20
|
-
utc: self.start.utc.iso8601
|
21
|
-
},
|
22
|
-
:end => {
|
23
|
-
timezone: Time.zone.tzinfo.name,
|
24
|
-
utc: self.end.utc.iso8601
|
25
|
-
},
|
26
|
-
currency: "MYR",
|
27
|
-
online_event: self.online_event
|
28
|
-
}
|
29
|
-
|
30
|
-
super()
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|