-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jim Mlodgenski
committed
Jan 29, 2019
1 parent
dc28c07
commit 1e1ef1a
Showing
23 changed files
with
604 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
class Attendee | ||
require 'json' | ||
|
||
attr_accessor :type | ||
attr_accessor :data | ||
|
||
class Data < Attendee | ||
attr_accessor :id | ||
attr_accessor :type | ||
attr_accessor :event | ||
attr_accessor :registrant | ||
|
||
class Type < Data | ||
attr_accessor :id | ||
attr_accessor :name | ||
end | ||
|
||
class Event < Data | ||
attr_accessor :url | ||
attr_accessor :name | ||
end | ||
|
||
class Registrant < Data | ||
attr_accessor :first_name | ||
attr_accessor :last_name | ||
attr_accessor :job_title | ||
attr_accessor :company | ||
attr_accessor :phone | ||
attr_accessor :email | ||
attr_accessor :address | ||
|
||
class Address < Registrant | ||
attr_accessor :street_address | ||
attr_accessor :extended_address | ||
attr_accessor :locality | ||
attr_accessor :region | ||
attr_accessor :postal_code | ||
attr_accessor :country | ||
end | ||
|
||
class Ticket < Registrant | ||
attr_accessor :ticket_type | ||
attr_accessor :paid | ||
attr_accessor :cost | ||
attr_accessor :token | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
class Boomset | ||
require 'rest-client' | ||
require 'json' | ||
|
||
def self.get_attendee_request(token, event_id) | ||
ret = {} | ||
auth = "Token " + token | ||
content_type = "application/json" | ||
|
||
url = "https://api.boomset.com/events/" + event_id.to_s + "/registration_types/" | ||
|
||
response = RestClient.get url, {content_type: content_type, authorization: auth} | ||
|
||
if response.code == 200 | ||
json = JSON.parse response.body | ||
json["results"].each do |result| | ||
ret[result["name"]] = result["id"] | ||
end | ||
end | ||
|
||
ret | ||
|
||
rescue RestClient::Exception | ||
ret | ||
end | ||
|
||
def self.add_guest(token, event_id, guest) | ||
auth = "Token " + token | ||
content_type = "application/json" | ||
|
||
url = "https://api.boomset.com/events/" + event_id.to_s + "/guests" | ||
|
||
response = RestClient.post url, guest, {content_type: content_type, authorization: auth} | ||
|
||
if response.code == 201 | ||
json = JSON.parse response.body | ||
json["id"] | ||
end | ||
|
||
rescue RestClient::Exception | ||
-1 | ||
end | ||
|
||
def self.update_guest(token, event_id, guest_id, guest) | ||
auth = "Token " + token | ||
content_type = "application/json" | ||
|
||
url = "https://api.boomset.com/events/" + event_id.to_s + "/guests/" + guest_id.to_s | ||
|
||
RestClient.put url, guest, {content_type: content_type, authorization: auth} | ||
|
||
if response.code == 200 | ||
json = JSON.parse response.body | ||
json["id"] | ||
end | ||
|
||
rescue RestClient::BadRequest => e | ||
puts e.response | ||
-1 | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
class BoomsetAttendee | ||
require 'json' | ||
|
||
attr_accessor :registration_type | ||
attr_accessor :first_name | ||
attr_accessor :last_name | ||
attr_accessor :email | ||
attr_accessor :prefix | ||
attr_accessor :suffix | ||
attr_accessor :phone | ||
attr_accessor :cell_phone | ||
attr_accessor :company | ||
attr_accessor :job_title | ||
attr_accessor :work_phone | ||
attr_accessor :blog | ||
attr_accessor :website | ||
attr_accessor :barcode | ||
attr_accessor :nfc_tag | ||
|
||
end |
61 changes: 61 additions & 0 deletions
61
app/controllers/admin/boomset_ticket_configs_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
module Admin | ||
class BoomsetTicketConfigsController < Admin::BaseController | ||
load_and_authorize_resource :conference, find_by: :short_title | ||
load_and_authorize_resource :boomset_ticket_config, through: :conference | ||
|
||
def index | ||
end | ||
|
||
def new | ||
@boomset_ticket_config = @conference.boomset_ticket_configs.new | ||
@integration = BoomsetTicketConfig.get_boomset_integration(@conference) | ||
@reg_types = BoomsetTicketConfig.get_registration_types(@integration) | ||
end | ||
|
||
def create | ||
@boomset_ticket_config = @conference.boomset_ticket_configs.new(boomset_ticket_config_params) | ||
@integration = BoomsetTicketConfig.get_boomset_integration(@conference) | ||
@boomset_ticket_config.integration = @integration | ||
|
||
if @boomset_ticket_config.save | ||
redirect_to admin_conference_boomset_ticket_configs_path(conference_id: @conference.short_title), | ||
notice: 'Boomset ticket successfully created.' | ||
else | ||
flash[:error] = "Creating Boomset ticket failed: #{@integration.errors.full_messages.join('. ')}." | ||
render :new | ||
end | ||
end | ||
|
||
def edit | ||
@integration = BoomsetTicketConfig.get_boomset_integration(@conference) | ||
@reg_types = BoomsetTicketConfig.get_registration_types(@integration) | ||
end | ||
|
||
def update | ||
if @boomset_ticket_config.update_attributes(boomset_ticket_config_params) | ||
redirect_to admin_conference_boomset_ticket_configs_path(conference_id: @conference.short_title), | ||
notice: 'Boomset ticket successfully updated.' | ||
else | ||
flash[:error] = "Update Boomset ticket failed: #{@boomset_ticket_config.errors.full_messages.join('. ')}." | ||
render :edit | ||
end | ||
end | ||
|
||
def destroy | ||
if @boomset_ticket_config.destroy | ||
redirect_to admin_conference_boomset_ticket_configs_path(conference_id: @conference.short_title), | ||
notice: 'Boomset ticket successfully deleted.' | ||
else | ||
redirect_to admin_conference_boomset_ticket_configs_path(conference_id: @conference.short_title), | ||
error: 'Deleting Boomset ticket failed.' \ | ||
"#{@boomset_ticket_config.errors.full_messages.join('. ')}." | ||
end | ||
end | ||
|
||
private | ||
|
||
def boomset_ticket_config_params | ||
params.require(:boomset_ticket_config).permit(:boomset_registration_type, :ticket_id, :integration_id, :conference_id) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
module Admin | ||
class IntegrationsController < Admin::BaseController | ||
load_and_authorize_resource :conference, find_by: :short_title | ||
load_and_authorize_resource :integration, through: :conference | ||
|
||
def index | ||
end | ||
|
||
def new | ||
@integration = @conference.integrations.new | ||
end | ||
|
||
def create | ||
@integration = @conference.integrations.new(integration_params) | ||
if @integration.save | ||
redirect_to admin_conference_integrations_path(conference_id: @conference.short_title), | ||
notice: 'Integration successfully created.' | ||
else | ||
flash[:error] = "Creating Integration failed: #{@integration.errors.full_messages.join('. ')}." | ||
render :new | ||
end | ||
end | ||
|
||
def edit; end | ||
|
||
def update | ||
if @integration.update_attributes(integration_params) | ||
redirect_to admin_conference_integrations_path(conference_id: @conference.short_title), | ||
notice: 'Integration successfully updated.' | ||
else | ||
flash[:error] = "Update Integration failed: #{@integration.errors.full_messages.join('. ')}." | ||
render :edit | ||
end | ||
end | ||
|
||
def destroy | ||
if @integration.destroy | ||
redirect_to admin_conference_integrations_path(conference_id: @conference.short_title), | ||
notice: 'Integration successfully deleted.' | ||
else | ||
redirect_to admin_conference_integrations_path(conference_id: @conference.short_title), | ||
error: 'Deleting integration failed.' \ | ||
"#{@integration.errors.full_messages.join('. ')}." | ||
end | ||
end | ||
|
||
private | ||
|
||
def integration_params | ||
params.require(:integration).permit(:integration_type, :key, :url, :integration_config_key, :conference_id) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
class BoomsetAttendeeRegisterJob < ActiveJob::Base | ||
require 'rest-client' | ||
require 'json' | ||
|
||
def self.perform(registration) | ||
guest = BoomsetGuest.get_guest(registration) | ||
|
||
integration = BoomsetTicketConfig.get_boomset_integration(registration.conference) | ||
if integration.integration_type == "boomset" | ||
guest_exists = false | ||
|
||
boomset_guest = BoomsetGuest.where(conference_id: registration.conference.id, token: guest.barcode).first | ||
if boomset_guest.blank? | ||
boomset_guest = BoomsetGuest.where(conference_id: registration.conference.id, registration_id: registration.id).first | ||
if boomset_guest.present? | ||
guest_exists = true | ||
end | ||
else | ||
guest_exists = true | ||
end | ||
|
||
if guest_exists | ||
id = Boomset.update_guest(integration.key, integration.integration_config_key, boomset_guest.boomset_guest, guest.to_json) | ||
if id > 0 | ||
boomset_guest.registration_id = registration.id | ||
boomset_guest.boomset_guest = id | ||
boomset_guest.update | ||
end | ||
else | ||
id = Boomset.add_guest(integration.key, integration.integration_config_key, guest.to_json) | ||
if id > 0 | ||
token = guest.barcode | ||
bg = BoomsetGuest.new | ||
bg.conference_id = registration.conference.id | ||
bg.registration_id = registration.id | ||
bg.integration_id = integration.id | ||
bg.boomset_guest = id | ||
bg.token = token | ||
bg.save | ||
end | ||
end | ||
end | ||
|
||
|
||
end | ||
|
||
end |
Oops, something went wrong.