Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions examples/endpoints/attendance_type.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

require_relative 'endpoint_helper'

attendance_type = @client.attendance_type(331_574)
print_attendance_type(attendance_type)
6 changes: 6 additions & 0 deletions examples/endpoints/attendance_types.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

require_relative 'endpoint_helper'

attendance_types = @client.attendance_types
print_attendance_types(attendance_types)
6 changes: 6 additions & 0 deletions examples/endpoints/event.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

require_relative 'endpoint_helper'

event = @client.event(968_614)
print_event(event)
6 changes: 6 additions & 0 deletions examples/endpoints/event_time.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

require_relative 'endpoint_helper'

event_time = @client.event_time(57_370_593)
print_event_time(event_time)
6 changes: 6 additions & 0 deletions examples/endpoints/event_times.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

require_relative 'endpoint_helper'

event_times = @client.event_times
print_event_times(event_times)
6 changes: 6 additions & 0 deletions examples/endpoints/events.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

require_relative 'endpoint_helper'

events = @client.events
print_events(events)
6 changes: 6 additions & 0 deletions examples/endpoints/headcount.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

require_relative 'endpoint_helper'

headcount = @client.headcount(12_693_102)
print_headcount(headcount)
6 changes: 6 additions & 0 deletions examples/endpoints/headcounts.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

require_relative 'endpoint_helper'

headcounts = @client.headcounts
print_headcounts(headcounts)
17 changes: 17 additions & 0 deletions examples/helpers/attendance_types.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

def print_attendance_types(list)
print_list('attendance_type', 'id', list, %w[data])
end

def print_attendance_type(item)
print_item('attendance_type', item, %w[data])
end

def attendance_type_columns
%w[
id
name
limit
]
end
23 changes: 23 additions & 0 deletions examples/helpers/event_times.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

def print_event_times(list)
print_list('event_time', 'id', list, %w[data])
end

def print_event_time(item)
print_item('event_time', item, %w[data])
end

def event_time_columns
%w[
id
name
day_of_week
hour
minute
regular_count
guest_count
volunteer_count
total_count
]
end
17 changes: 17 additions & 0 deletions examples/helpers/events.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

def print_events(list)
print_list('event', 'id', list, %w[data])
end

def print_event(item)
print_item('event', item, %w[data])
end

def event_columns
%w[
id
name
frequency
]
end
16 changes: 16 additions & 0 deletions examples/helpers/headcounts.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

def print_headcounts(list)
print_list('headcount', 'id', list, %w[data])
end

def print_headcount(item)
print_item('headcount', item, %w[data])
end

def headcount_columns
%w[
id
total
]
end
4 changes: 4 additions & 0 deletions lib/planning_center/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@
module PlanningCenter
class Client
include PlanningCenter::Endpoints::Addresses
include PlanningCenter::Endpoints::AttendanceTypes
include PlanningCenter::Endpoints::Campuses
include PlanningCenter::Endpoints::DesignationRefunds
include PlanningCenter::Endpoints::Donations
include PlanningCenter::Endpoints::Emails
include PlanningCenter::Endpoints::Events
include PlanningCenter::Endpoints::EventTimes
include PlanningCenter::Endpoints::FieldData
include PlanningCenter::Endpoints::FieldDefinitions
include PlanningCenter::Endpoints::FieldOptions
include PlanningCenter::Endpoints::Funds
include PlanningCenter::Endpoints::Groups
include PlanningCenter::Endpoints::GroupTypes
include PlanningCenter::Endpoints::Headcounts
include PlanningCenter::Endpoints::Households
include PlanningCenter::Endpoints::InactiveReasons
include PlanningCenter::Endpoints::InKindDonations
Expand Down
23 changes: 23 additions & 0 deletions lib/planning_center/endpoints/attendance_types.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

module PlanningCenter
module Endpoints
module AttendanceTypes
def attendance_type(id, params = {})
get(
"check-ins/v2/attendance_types/#{id}",
params
)
end

def attendance_types(params = {})
# We need to order the attendance_types by a value (created_at being the default),
# because the results are not consistently ordered without it.
get(
'check-ins/v2/attendance_types',
{ order: :created_at }.merge(params)
)
end
end
end
end
23 changes: 23 additions & 0 deletions lib/planning_center/endpoints/event_times.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

module PlanningCenter
module Endpoints
module EventTimes
def event_time(id, params = {})
get(
"check-ins/v2/event_times/#{id}",
params
)
end

def event_times(params = {})
# We need to order the event_times by a value (created_at being the default),
# because the results are not consistently ordered without it.
get(
'check-ins/v2/event_times',
{ order: :created_at }.merge(params)
)
end
end
end
end
23 changes: 23 additions & 0 deletions lib/planning_center/endpoints/events.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

module PlanningCenter
module Endpoints
module Events
def event(id, params = {})
get(
"check-ins/v2/events/#{id}",
params
)
end

def events(params = {})
# We need to order the events by a value (created_at being the default),
# because the results are not consistently ordered without it.
get(
'check-ins/v2/events',
{ order: :created_at }.merge(params)
)
end
end
end
end
23 changes: 23 additions & 0 deletions lib/planning_center/endpoints/headcounts.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

module PlanningCenter
module Endpoints
module Headcounts
def headcount(id, params = {})
get(
"check-ins/v2/headcounts/#{id}",
params
)
end

def headcounts(params = {})
# We need to order the headcounts by a value (created_at being the default),
# because the results are not consistently ordered without it.
get(
'check-ins/v2/headcounts',
{ order: :created_at }.merge(params)
)
end
end
end
end
37 changes: 37 additions & 0 deletions spec/planning_center/endpoints/attendance_types_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe PlanningCenter::Endpoints::AttendanceTypes do
let!(:client) { FactoryBot.build(:client) }

describe '#attendance_types', :vcr do
before do
@attendance_types = client.attendance_types(per_page: 25).body
end

it 'returns an array' do
expect(@attendance_types['data']).to be_an(Array)
end

it 'returns the correct number of objects' do
expect(@attendance_types['data'].count).to eq 1
end

it 'returns attendance_types objects' do
expect(@attendance_types['data'].first).to be_a(Hash)
expect(@attendance_types['data'].first['id']).to_not be_nil
end
end

describe '#attendance_type', :vcr do
before do
@attendance_type = client.attendance_type(331_574).body
end

it 'returns a attendance_type object' do
expect(@attendance_type).to be_a(Hash)
expect(@attendance_type['data']['id']).to eq('331574')
end
end
end
37 changes: 37 additions & 0 deletions spec/planning_center/endpoints/event_times_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe PlanningCenter::Endpoints::EventTimes do
let!(:client) { FactoryBot.build(:client) }

describe '#event_times', :vcr do
before do
@event_times = client.event_times(per_page: 25).body
end

it 'returns an array' do
expect(@event_times['data']).to be_an(Array)
end

it 'returns the correct number of objects' do
expect(@event_times['data'].count).to eq 1
end

it 'returns event_times objects' do
expect(@event_times['data'].first).to be_a(Hash)
expect(@event_times['data'].first['id']).to_not be_nil
end
end

describe '#event_time', :vcr do
before do
@event_time = client.event_time(57_370_593).body
end

it 'returns a event_time object' do
expect(@event_time).to be_a(Hash)
expect(@event_time['data']['id']).to eq('57370593')
end
end
end
37 changes: 37 additions & 0 deletions spec/planning_center/endpoints/events_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe PlanningCenter::Endpoints::Events do
let!(:client) { FactoryBot.build(:client) }

describe '#events', :vcr do
before do
@events = client.events(per_page: 25).body
end

it 'returns an array' do
expect(@events['data']).to be_an(Array)
end

it 'returns the correct number of objects' do
expect(@events['data'].count).to eq 1
end

it 'returns events objects' do
expect(@events['data'].first).to be_a(Hash)
expect(@events['data'].first['id']).to_not be_nil
end
end

describe '#event', :vcr do
before do
@event = client.event(968_614).body
end

it 'returns a event object' do
expect(@event).to be_a(Hash)
expect(@event['data']['id']).to eq('968614')
end
end
end
Loading
Loading