cronofy 0.20.0 → 0.21.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 522370b2f01af27ff60bacbb76323ca47dd077b1
4
- data.tar.gz: 716a6013058ba2216fe70ac96b755bc6533ba24e
3
+ metadata.gz: 0b09683a6a1a610a1f4e0790c918b85a403676e4
4
+ data.tar.gz: d79520d6abb9e4c51d07b0dc59eb020205c61624
5
5
  SHA512:
6
- metadata.gz: b8bdf1cbb735736f76700aad41b083be051b5d821e03a088c54b537c066743ee51390fc73daa6875b8ecc78ee22e5c6c127d8b94532ee3af0b492cd4270b8acf
7
- data.tar.gz: 5bb3db55ed8cd3e9f71320bdb13f1e754d9f9bf47b049d8d87c3a2be74fc668c4c21c0f352fb4147ef1bd54762b39c03e2f004b6ade724ba9ff3f0011b4c04fb
6
+ metadata.gz: f1f7adbeaa413a282fd1d930984b9d52215326959ff3f62f690dade3210ac2f98af7701e3fc2a1975373b8275c0b0120cddf3f0cd653588309a9898089a3c0d4
7
+ data.tar.gz: ccb144468e56a76d91f1917647e8e0f405fa9493d66fb517d274d846acfaa418465ce052defba90e9d999e3a0734caa720c31e815a9f2cf2982f17db19b12317
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.21.0]
2
+
3
+ * Support Add To Calendar with availability [#40]
4
+
1
5
  ## [0.20.0]
2
6
 
3
7
  * Change invalid request message to include errors [#36]
@@ -53,6 +57,7 @@
53
57
  [0.18.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.18.0
54
58
  [0.19.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.19.0
55
59
  [0.20.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.20.0
60
+ [0.21.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.20.0
56
61
 
57
62
  [#13]: https://github.com/cronofy/cronofy-ruby/pull/13
58
63
  [#16]: https://github.com/cronofy/cronofy-ruby/pull/16
@@ -68,3 +73,4 @@
68
73
  [#36]: https://github.com/cronofy/cronofy-ruby/pull/36
69
74
  [#37]: https://github.com/cronofy/cronofy-ruby/pull/37
70
75
  [#38]: https://github.com/cronofy/cronofy-ruby/pull/38
76
+ [#40]: https://github.com/cronofy/cronofy-ruby/pull/40
@@ -711,58 +711,67 @@ module Cronofy
711
711
  # Public: Generates an add to calendar link to start the OAuth process with
712
712
  # an event to be automatically upserted
713
713
  #
714
- # oauth - A Hash describing the OAuth flow required:
715
- # :scope - A String representing the scopes to ask for
716
- # within the OAuth flow
717
- # :redirect_uri - A String containing a url to redirect the
718
- # user to after completing the OAuth flow.
719
- # :scope - A String representing additional state to
720
- # be passed within the OAuth flow.
721
- #
722
- # event - A Hash describing the event with symbolized keys:
723
- # :event_id - A String uniquely identifying the event for
724
- # your application (note: this is NOT an ID
725
- # generated by Cronofy).
726
- # :summary - A String to use as the summary, sometimes
727
- # referred to as the name or title, of the
728
- # event.
729
- # :description - A String to use as the description, sometimes
730
- # referred to as the notes or body, of the
731
- # event.
732
- # :start - The Time or Date the event starts.
733
- # :end - The Time or Date the event ends.
734
- # :url - The URL associated with the event.
735
- # :location - A Hash describing the location of the event
736
- # with symbolized keys (optional):
737
- # :description - A String describing the
738
- # location.
739
- # :lat - A String of the location's latitude.
740
- # :long - A String of the location's longitude.
741
- # :reminders - An Array of Hashes describing the desired
742
- # reminders for the event. Reminders should be
743
- # specified in priority order as, for example,
744
- # when the underlying provider only supports a
745
- # single reminder then the first reminder will
746
- # be used.
747
- # :minutes - An Integer specifying the number
748
- # of minutes before the start of the
749
- # event that the reminder should
750
- # occur.
751
- # :transparency - The transparency state for the event (optional).
752
- # Accepted values are "transparent" and "opaque".
753
- # :attendees - A Hash of :invite and :reject, each of which is
754
- # an array of invitees to invite to or reject from
755
- # the event. Invitees are represented by a hash of
756
- # :email and :display_name (optional).
714
+ # oauth - A Hash describing the OAuth flow required:
715
+ # :scope - A String representing the scopes to ask for
716
+ # within the OAuth flow
717
+ # :redirect_uri - A String containing a url to redirect the
718
+ # user to after completing the OAuth flow.
719
+ # :scope - A String representing additional state to
720
+ # be passed within the OAuth flow.
721
+ #
722
+ # event - A Hash describing the event with symbolized keys:
723
+ # :event_id - A String uniquely identifying the event for
724
+ # your application (note: this is NOT an ID
725
+ # generated by Cronofy).
726
+ # :summary - A String to use as the summary, sometimes
727
+ # referred to as the name or title, of the
728
+ # event.
729
+ # :description - A String to use as the description, sometimes
730
+ # referred to as the notes or body, of the
731
+ # event.
732
+ # :start - The Time or Date the event starts.
733
+ # :end - The Time or Date the event ends.
734
+ # :url - The URL associated with the event.
735
+ # :location - A Hash describing the location of the event
736
+ # with symbolized keys (optional):
737
+ # :description - A String describing the
738
+ # location.
739
+ # :lat - A String of the location's latitude.
740
+ # :long - A String of the location's longitude.
741
+ # :reminders - An Array of Hashes describing the desired
742
+ # reminders for the event. Reminders should be
743
+ # specified in priority order as, for example,
744
+ # when the underlying provider only supports a
745
+ # single reminder then the first reminder will
746
+ # be used.
747
+ # :minutes - An Integer specifying the number
748
+ # of minutes before the start of the
749
+ # event that the reminder should
750
+ # occur.
751
+ # :transparency - The transparency state for the event (optional).
752
+ # Accepted values are "transparent" and "opaque".
753
+ # :attendees - A Hash of :invite and :reject, each of which is
754
+ # an array of invitees to invite to or reject from
755
+ # the event. Invitees are represented by a hash of
756
+ # :email and :display_name (optional).
757
+ # availability - A Hash describing the availability details for the event:
758
+ # :participants - A hash stating who is required for the availability
759
+ # call
760
+ # :required_duration - A hash stating the length of time the event will
761
+ # last for
762
+ # :available_periods - A hash stating the available periods for the event
763
+ # target_calendars - An array of hashes stating into which calendars to insert the created
764
+ # event
757
765
  #
758
766
  # Examples
759
767
  #
768
+ # - OAuth example
760
769
  # client.add_to_calendar(
761
770
  # oauth: {
762
771
  # scopes: 'read_events delete_events',
763
772
  # redirect_uri: 'http://www.example.com',
764
773
  # state: 'example_state'
765
- # }
774
+ # },
766
775
  # event: {
767
776
  # event_id: "qTtZdczOccgaPncGJaCiLg",
768
777
  # summary: "Board meeting",
@@ -775,6 +784,43 @@ module Cronofy
775
784
  # long: "0.1234"
776
785
  # })
777
786
  #
787
+ # - Availability example
788
+ # client.add_to_calendar(
789
+ # oauth: {
790
+ # redirect_uri: 'http://www.example.com'
791
+ # },
792
+ # event: {
793
+ # event_id: "qTtZdczOccgaPncGJaCiLg",
794
+ # summary: "Board meeting",
795
+ # description: "Discuss plans for the next quarter.",
796
+ # location: {
797
+ # description: "Board room",
798
+ # lat: "1.2345",
799
+ # long: "0.1234"
800
+ # }
801
+ # },
802
+ # availability: {
803
+ # participants: [
804
+ # {
805
+ # members: [{
806
+ # sub: "acc_567236000909002",
807
+ # calendar_ids: ["cal_n23kjnwrw2_jsdfjksn234"]
808
+ # }],
809
+ # required: 'all'
810
+ # }
811
+ # ],
812
+ # required_duration: { minutes: 60 },
813
+ # available_periods: [{
814
+ # start: Time.utc(2017, 1, 1, 9, 00),
815
+ # end: Time.utc(2017, 1, 1, 17, 00),
816
+ # }]
817
+ # },
818
+ # target_calendars: [{
819
+ # sub: "acc_567236000909002",
820
+ # calendar_id: "cal_n23kjnwrw2_jsdfjksn234"
821
+ # }]
822
+ # )
823
+ #
778
824
  # See http://www.cronofy.com/developers/api#upsert-event for reference.
779
825
  #
780
826
  # Returns a AddToCalendarResponse.
@@ -790,12 +836,15 @@ module Cronofy
790
836
  # Raises Cronofy::TooManyRequestsError if the request exceeds the rate
791
837
  # limits for the application.
792
838
  def add_to_calendar(args = {})
793
- body = {
794
- client_id: @client_id,
795
- client_secret: @client_secret,
796
- oauth: args[:oauth],
797
- event: args[:event],
798
- }
839
+ body = args.merge(client_id: @client_id, client_secret: @client_secret)
840
+
841
+ if availability = body[:availability]
842
+ availability[:participants] = map_availability_participants(availability[:participants])
843
+ availability[:required_duration] = map_availability_required_duration(availability[:required_duration])
844
+
845
+ translate_available_periods(availability[:available_periods])
846
+ body[:availability] = availability
847
+ end
799
848
 
800
849
  body[:event][:start] = encode_event_time(body[:event][:start]) if body[:event][:start]
801
850
  body[:event][:end] = encode_event_time(body[:event][:end]) if body[:event][:end]
@@ -1,3 +1,3 @@
1
1
  module Cronofy
2
- VERSION = "0.20.0".freeze
2
+ VERSION = "0.21.0".freeze
3
3
  end
@@ -1437,9 +1437,19 @@ describe Cronofy::Client do
1437
1437
  {
1438
1438
  oauth: oauth_body,
1439
1439
  event: event,
1440
+ target_calendars: target_calendars,
1440
1441
  }
1441
1442
  end
1442
1443
 
1444
+ let(:target_calendars) do
1445
+ [
1446
+ {
1447
+ sub: "acc_567236000909002",
1448
+ calendar_id: "cal_n23kjnwrw2_jsdfjksn234",
1449
+ }
1450
+ ]
1451
+ end
1452
+
1443
1453
  let(:request_body) do
1444
1454
  {
1445
1455
  client_id: client_id,
@@ -1459,7 +1469,151 @@ describe Cronofy::Client do
1459
1469
  { :minutes => 0 },
1460
1470
  { :minutes => 10 },
1461
1471
  ],
1472
+ },
1473
+ target_calendars: target_calendars,
1474
+ }
1475
+ end
1476
+ let(:correct_response_code) { 202 }
1477
+ let(:correct_response_body) do
1478
+ {
1479
+ oauth_url: "http://www.example.com/oauth?token=example"
1480
+ }
1481
+ end
1482
+
1483
+ subject { client.add_to_calendar(args) }
1484
+
1485
+ context 'when start/end are Times' do
1486
+ it_behaves_like 'a Cronofy request'
1487
+ end
1488
+
1489
+ end
1490
+
1491
+ describe "Add to calendar availability" do
1492
+ let(:request_url) { "https://api.cronofy.com/v1/add_to_calendar" }
1493
+ let(:url) { URI("https://example.com") }
1494
+ let(:method) { :post }
1495
+ let(:request_headers) { json_request_headers }
1496
+
1497
+ let(:start_datetime) { Time.utc(2014, 8, 5, 15, 30, 0) }
1498
+ let(:end_datetime) { Time.utc(2014, 8, 5, 17, 0, 0) }
1499
+ let(:encoded_start_datetime) { "2014-08-05T15:30:00Z" }
1500
+ let(:encoded_end_datetime) { "2014-08-05T17:00:00Z" }
1501
+ let(:location) { { :description => "Board room" } }
1502
+ let(:transparency) { nil }
1503
+ let(:client_id) { 'example_id' }
1504
+ let(:client_secret) { 'example_secret' }
1505
+ let(:scope) { 'read_events delete_events' }
1506
+ let(:state) { 'example_state' }
1507
+ let(:redirect_uri) { 'http://example.com/redirect' }
1508
+
1509
+ let(:client) do
1510
+ Cronofy::Client.new(
1511
+ client_id: client_id,
1512
+ client_secret: client_secret,
1513
+ access_token: token,
1514
+ )
1515
+ end
1516
+
1517
+ let(:event) do
1518
+ {
1519
+ :event_id => "qTtZdczOccgaPncGJaCiLg",
1520
+ :summary => "Board meeting",
1521
+ :description => "Discuss plans for the next quarter.",
1522
+ :url => url,
1523
+ :location => location,
1524
+ :transparency => transparency,
1525
+ :reminders => [
1526
+ { :minutes => 60 },
1527
+ { :minutes => 0 },
1528
+ { :minutes => 10 },
1529
+ ],
1530
+ }
1531
+ end
1532
+
1533
+ let(:oauth_body) do
1534
+ {
1535
+ scope: scope,
1536
+ redirect_uri: redirect_uri,
1537
+ state: state,
1538
+ }
1539
+ end
1540
+
1541
+ let(:target_calendars) do
1542
+ [
1543
+ {
1544
+ sub: "acc_567236000909002",
1545
+ calendar_id: "cal_n23kjnwrw2_jsdfjksn234",
1462
1546
  }
1547
+ ]
1548
+ end
1549
+
1550
+ let(:availability) do
1551
+ {
1552
+ participants: [
1553
+ {
1554
+ members: [{
1555
+ sub: "acc_567236000909002",
1556
+ calendar_ids: ["cal_n23kjnwrw2_jsdfjksn234"]
1557
+ }],
1558
+ required: 'all'
1559
+ }
1560
+ ],
1561
+ required_duration: { minutes: 60 },
1562
+ available_periods: [{
1563
+ start: Time.utc(2017, 1, 1, 9, 00),
1564
+ end: Time.utc(2017, 1, 1, 17, 00),
1565
+ }]
1566
+ }
1567
+ end
1568
+
1569
+ let(:mapped_availability) do
1570
+ {
1571
+ participants: [
1572
+ {
1573
+ members: [{
1574
+ sub: "acc_567236000909002",
1575
+ calendar_ids: ["cal_n23kjnwrw2_jsdfjksn234"]
1576
+ }],
1577
+ required: 'all'
1578
+ }
1579
+ ],
1580
+ required_duration: { minutes: 60 },
1581
+ available_periods: [{
1582
+ start: "2017-01-01T09:00:00Z",
1583
+ end: "2017-01-01T17:00:00Z",
1584
+ }]
1585
+ }
1586
+ end
1587
+
1588
+ let(:args) do
1589
+ {
1590
+ oauth: oauth_body,
1591
+ event: event,
1592
+ target_calendars: target_calendars,
1593
+ availability: availability,
1594
+ }
1595
+ end
1596
+
1597
+ let(:request_body) do
1598
+ {
1599
+ client_id: client_id,
1600
+ client_secret: client_secret,
1601
+ oauth: oauth_body,
1602
+ event: {
1603
+ :event_id => "qTtZdczOccgaPncGJaCiLg",
1604
+ :summary => "Board meeting",
1605
+ :description => "Discuss plans for the next quarter.",
1606
+ :url => url.to_s,
1607
+ :location => location,
1608
+ :transparency => transparency,
1609
+ :reminders => [
1610
+ { :minutes => 60 },
1611
+ { :minutes => 0 },
1612
+ { :minutes => 10 },
1613
+ ],
1614
+ },
1615
+ target_calendars: target_calendars,
1616
+ availability: mapped_availability,
1463
1617
  }
1464
1618
  end
1465
1619
  let(:correct_response_code) { 202 }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cronofy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.0
4
+ version: 0.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergii Paryzhskyi
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-04-13 00:00:00.000000000 Z
12
+ date: 2017-04-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oauth2
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
149
  version: '0'
150
150
  requirements: []
151
151
  rubyforge_project:
152
- rubygems_version: 2.6.6
152
+ rubygems_version: 2.6.4
153
153
  signing_key:
154
154
  specification_version: 4
155
155
  summary: Cronofy - one API for all the calendars