Skip to content

Commit 771045e

Browse files
authored
Merge pull request #75 from apeluffo/add-remove-recipient-smart-invites
Add Support for Smart Invite Remove Participant
2 parents 2189ca4 + 9b87022 commit 771045e

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed

lib/cronofy/client.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,6 +1323,32 @@ def cancel_smart_invite(body={})
13231323
parse_json(SmartInviteResponse, nil, response)
13241324
end
13251325

1326+
# Public: Removes an individual recipient from a multiple recipient smart invite
1327+
#
1328+
# smart_invite_id - A String uniquely identifying the event for your
1329+
# application (note: this is NOT an ID generated
1330+
# by Cronofy).
1331+
#
1332+
# recipient - A Hash containing the recipient to be removed
1333+
# :email - A String for the email address of
1334+
# the recipient to remove.
1335+
#
1336+
# See https://docs.cronofy.com/developers/api-alpha/smart-invites/multiple-recipients/#remove-invite-recipient
1337+
# for reference.
1338+
#
1339+
# Returns a SmartInviteResponse
1340+
#
1341+
# Raises Cronofy::CredentialsMissingError if no credentials available.
1342+
# Raises Cronofy::InvalidRequestError if the request contains invalid
1343+
# parameters.
1344+
# Raises Cronofy::TooManyRequestsError if the request exceeds the rate
1345+
# limits for the application.
1346+
def remove_recipient_smart_invite(body={})
1347+
body[:method] = 'remove'
1348+
response = wrapped_request { api_key!.post("/v1/smart_invites", json_request_args(body)) }
1349+
parse_json(SmartInviteResponse, nil, response)
1350+
end
1351+
13261352
# Public: Gets the details for a smart invite.
13271353
#
13281354
# smart_invite_id - A String uniquely identifying the event for your

spec/lib/cronofy/client_spec.rb

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2630,6 +2630,67 @@
26302630

26312631
end
26322632

2633+
describe "Remove Recipient Smart Invite", test: true do
2634+
let(:request_url) { "https://api.cronofy.com/v1/smart_invites" }
2635+
let(:method) { :post }
2636+
2637+
let(:request_headers) do
2638+
{
2639+
"Authorization" => "Bearer #{client_secret}",
2640+
"User-Agent" => "Cronofy Ruby #{::Cronofy::VERSION}",
2641+
"Content-Type" => "application/json; charset=utf-8",
2642+
}
2643+
end
2644+
2645+
let(:client_id) { 'example_id' }
2646+
let(:client_secret) { 'example_secret' }
2647+
2648+
let(:client) do
2649+
Cronofy::Client.new(
2650+
client_id: client_id,
2651+
client_secret: client_secret,
2652+
)
2653+
end
2654+
2655+
let(:args) do
2656+
{
2657+
smart_invite_id: "qTtZdczOccgaPncGJaCiLg",
2658+
recipient: {
2659+
email: "example@example.com"
2660+
}
2661+
}
2662+
end
2663+
2664+
let(:request_body) do
2665+
{
2666+
method: 'remove',
2667+
smart_invite_id: "qTtZdczOccgaPncGJaCiLg",
2668+
recipient: {
2669+
email: "example@example.com"
2670+
}
2671+
}
2672+
end
2673+
let(:correct_response_code) { 202 }
2674+
let(:correct_response_body) do
2675+
request_body.merge({
2676+
attachments: {
2677+
removed: {
2678+
email: "example@example.com"
2679+
}
2680+
}
2681+
})
2682+
end
2683+
2684+
let(:correct_mapped_result) do
2685+
Cronofy::SmartInviteResponse.new(correct_response_body)
2686+
end
2687+
2688+
subject { client.remove_recipient_smart_invite(request_body) }
2689+
2690+
it_behaves_like 'a Cronofy request'
2691+
it_behaves_like 'a Cronofy request with mapped return value'
2692+
end
2693+
26332694
describe "Batch requests" do
26342695
context "upserting an event" do
26352696
let(:calendar_id) { 'calendar_id_123'}

0 commit comments

Comments
 (0)