action_kit_api 0.2.3 → 0.3.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.
@@ -20,7 +20,7 @@ module ActionKitApi
20
20
  def save
21
21
  class_name = self.class.to_s.split("::").last
22
22
 
23
- raise MissingRequiredAttributeException "Unable to save incomplete object" unless self.valid?
23
+ raise MissingRequiredAttributeException unless self.valid?
24
24
 
25
25
  attrs_hash = self.to_hash
26
26
  attrs_hash.delete_if do |k, v|
@@ -0,0 +1,33 @@
1
+ require 'action_kit_api'
2
+
3
+ module ActionKitApi
4
+ class Event < ApiDataModel
5
+ include Searchable
6
+
7
+ # Required
8
+ attr_accessor :id, :campaign, :creator, :title
9
+
10
+ # Other/Active
11
+ attr_accessor :address1, :address2, :attendee_count, :city, :country,
12
+ :directions, :ends_at, :host_is_confirmed, :is_approved,
13
+ :is_full, is_in_past, :is_open_for_signup, :is_private,
14
+ :latitude, :longitude, :max_attendees, :note_to_attendees,
15
+ :notes, :phone, :plus4, :postal, :public_description, :region,
16
+ :starts_at, :state, :status, :status_summary, :venue, :zip
17
+
18
+ def initialize(*args)
19
+ @required_attrs = [:campaign, :creator, :title]
20
+ @read_only_attrs =[:attendee_count]
21
+
22
+ super
23
+ end
24
+
25
+ def cancel
26
+ raise "Can't cancel unsaved Event" if self.id.nil?
27
+
28
+ status "cancelled"
29
+ save
30
+ end
31
+ end
32
+ end
33
+
@@ -0,0 +1,60 @@
1
+ require 'action_kit_api'
2
+
3
+ module ActionKitApi
4
+ class EventCampaign < ApiDataModel
5
+ include Searchable
6
+
7
+ # Required
8
+ attr_accessor :id, :name, :title
9
+
10
+ # Other/Active
11
+ attr_accessor :allow_private, :default_event_size, :default_title,
12
+ :max_event_size, :public_create_page,
13
+ :public_search_page, :require_email_confirmation,
14
+ :require_staff_approval, :show_address1,
15
+ :show_public_description, :show_state, :show_title,
16
+ :show_venue, :show_zip, :starts_at, :use_start_date,
17
+ :use_start_time, :use_title
18
+
19
+ def initialize(*args)
20
+ @required_attrs = [:name, :title]
21
+
22
+ super
23
+
24
+ @default_title ||= @title
25
+ @default_event_size ||= 35
26
+ @show_address1 ||= true
27
+ end
28
+
29
+ def create_event(*args)
30
+ raise "EventCampaign needs to be saved before Event creation" if self.id.nil?
31
+
32
+ args[0][:campaign] = self.id
33
+ Event.new(args)
34
+ end
35
+
36
+ # Uses public_search so is subject those limitations
37
+ def find_local_events(zip, radius)
38
+ self.public_search(:zip => zip, :radius => radius)
39
+ end
40
+
41
+ # Will not return private events, events that are full, deleted, or in the past
42
+ # and doesn't return extra fields
43
+ def public_search(*args)
44
+ args[0][:campaign] ||= self.id
45
+ results = ActionKitApi.connection.call("EventCampaign.public_search", args)
46
+
47
+ results.map do |r|
48
+ Event.new(r)
49
+ end
50
+
51
+ results
52
+ end
53
+
54
+ def stats
55
+ raise "EventCampaign needs to be saved before retrieving stats" if self.id.nil?
56
+
57
+ ActionKitApi.connection.call("EventCampaign.stats", {:id => self.id})
58
+ end
59
+ end
60
+ end
@@ -1,3 +1,3 @@
1
1
  module ActionKitApi
2
- VERSION = "0.2.3"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -8,6 +8,8 @@ require "action_kit_api/data_model"
8
8
  require "action_kit_api/user"
9
9
  require "action_kit_api/page"
10
10
  require "action_kit_api/action"
11
+ require "action_kit_api/event"
12
+ require "action_kit_api/event_campaign"
11
13
 
12
14
  # Page types
13
15
  require "action_kit_api/page_types/petition"
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 2
8
7
  - 3
9
- version: 0.2.3
8
+ - 0
9
+ version: 0.3.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Sam Stelfox
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2012-03-12 00:00:00 -04:00
17
+ date: 2012-03-13 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -70,6 +70,8 @@ files:
70
70
  - lib/action_kit_api/actionkit_ca_chain.pem
71
71
  - lib/action_kit_api/connection.rb
72
72
  - lib/action_kit_api/data_model.rb
73
+ - lib/action_kit_api/event.rb
74
+ - lib/action_kit_api/event_campaign.rb
73
75
  - lib/action_kit_api/page.rb
74
76
  - lib/action_kit_api/page_types/import.rb
75
77
  - lib/action_kit_api/page_types/petition.rb