eventbrite_sdk 3.4.0 → 3.6.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2c1e67123425f40c0f27d858eb440c95f5a19d2d
4
- data.tar.gz: a7e48208c305d9bc8e89525c73097114bd6821f5
3
+ metadata.gz: 6c404806f54b4030c3f5d46eb24f032d7efa90a4
4
+ data.tar.gz: 5a748033c1fc2416359d5a0b988d3c0d43c32d23
5
5
  SHA512:
6
- metadata.gz: c40cc4297d6aa7c915ff70c5580b4c32f2193191eaec752e69bef68d5912d9156bf3d8187ae5fcbf7cc9c5f5c1e0b592b09c939b9c7813f83cbba48db1538e25
7
- data.tar.gz: 8d1b496743e38f269e3c8cd23b843ac47c185b7d825294c810ec5937ad22bb20f67fcade02a4efa4b948c31d717813ea1bb28aac6bb862104322e70aa4b38ac9
6
+ metadata.gz: 0274a3d9e0e3205e49edd0be92ec94b0ad3076e621f47da10376a3f637b11f891ecc64b9c9be41b43e0209125005c72802224e591e672a20f7dcff615ca06913
7
+ data.tar.gz: 9687f9cb26715fd0b3afb0f16ce854407ba44b82f4173ad4ed0753c249ca13315885aede36a77b483ef456713173d4fc7f714b7b250e575a706b5fe497403690
data/.gitignore CHANGED
@@ -2,3 +2,4 @@ Gemfile.lock
2
2
  .byebug_history
3
3
  coverage/
4
4
  tmp/
5
+ .ruby-version
data/README.md CHANGED
@@ -2,9 +2,6 @@
2
2
 
3
3
  [![Code Climate](https://codeclimate.com/github/eventbrite/eventbrite-sdk-ruby/badges/gpa.svg)](https://codeclimate.com/github/eventbrite/eventbrite-sdk-ruby) [![Issue Count](https://codeclimate.com/github/eventbrite/eventbrite-sdk-ruby/badges/issue_count.svg)](https://codeclimate.com/github/eventbrite/eventbrite-sdk-ruby) [![Build Status](https://travis-ci.org/eventbrite/eventbrite-sdk-ruby.svg?branch=master)](https://travis-ci.org/eventbrite/eventbrite-sdk-ruby) [![Test Coverage](https://codeclimate.com/github/eventbrite/eventbrite-sdk-ruby/badges/coverage.svg)](https://codeclimate.com/github/eventbrite/eventbrite-sdk-ruby/coverage) [![Dependency Status](https://gemnasium.com/badges/github.com/eventbrite/eventbrite-sdk-ruby.svg)](https://gemnasium.com/github.com/eventbrite/eventbrite-sdk-ruby) [![Gem Version](https://badge.fury.io/rb/eventbrite_sdk.svg)](https://badge.fury.io/rb/eventbrite_sdk)
4
4
 
5
-
6
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/eventbrite_sdk`. To experiment with that code, run `bin/console` for an interactive prompt.
7
-
8
5
  ## Installation
9
6
 
10
7
  Add this line to your application's Gemfile:
@@ -69,13 +66,14 @@ your_event.save
69
66
  your_event.publish
70
67
 
71
68
  ```
69
+
72
70
  # Navigating paginated responses:
73
71
 
74
72
  ``` ruby
75
73
 
76
74
  EventbriteSDK.token = "TOKEN"
77
75
 
78
- # one feature of the Eventbrite API is that you can pass in the string 'me' in place of a
76
+ # one feature of the Eventbrite API is that you can pass in the string 'me' in place of a
79
77
  # user id and it will evaluate to the id of the user associated with the oauth token.
80
78
 
81
79
  # fetch a new user record using the Eventbrite user id
@@ -102,6 +100,18 @@ example.continue
102
100
  # you can also provide a token if you choose to do so
103
101
  example.continue(continuation_token: 'my_token')
104
102
  ```
103
+
104
+ # Use `#retrieve` to build up arbitrary queries
105
+
106
+ ``` ruby
107
+
108
+ # For example, to use the 'status' parameter seen here: https://www.eventbrite.com/developer/v3/endpoints/events/#ebapi-id78
109
+
110
+ user = EventbriteSDK::User.retrieve(id: 163054428874)
111
+ user.owned_events.retrieve(query: { status: 'live' })
112
+
113
+ ```
114
+
105
115
  # Construct endpoint paths:
106
116
 
107
117
  ``` ruby
@@ -130,7 +140,7 @@ order = EventbriteSDK::Order.retrieve(id: id, expand: [:attendees, :event])
130
140
 
131
141
  # Per-request Configuration
132
142
 
133
- For apps that need to use multiple tokens during the lifetime of a process, it is
143
+ For apps that need to use multiple tokens during the lifetime of a process, it is
134
144
  possible to set a per-request token:
135
145
 
136
146
  ``` ruby
@@ -161,7 +171,7 @@ will fall-back on the global token for the action called.
161
171
 
162
172
  # Shallow resource list endpoints
163
173
 
164
- Some paginated lists are available at the base of the resource url, webhooks and
174
+ Some paginated lists are available at the base of the resource url, webhooks and
165
175
  categories for example. The resources that have this trait will include the `Operations::List` module
166
176
 
167
177
  ``` ruby
@@ -20,8 +20,8 @@ Gem::Specification.new do |spec|
20
20
  spec.require_paths = ['lib']
21
21
 
22
22
  spec.add_dependency 'rest-client', '~> 2.0'
23
- spec.add_development_dependency 'bundler', '~> 1.12'
24
- spec.add_development_dependency 'rake', '~> 10.0'
23
+ spec.add_development_dependency 'bundler', '>= 2.1'
24
+ spec.add_development_dependency 'rake', '>= 12.3.3'
25
25
  spec.add_development_dependency 'rspec', '~> 3.0'
26
26
  spec.add_development_dependency 'simplecov', '~> 0.11'
27
27
  spec.add_development_dependency 'codeclimate-test-reporter', '~> 1.0'
@@ -22,9 +22,11 @@ require 'eventbrite_sdk/lists/owned_event_orders_list'
22
22
 
23
23
  require 'eventbrite_sdk/attendee'
24
24
  require 'eventbrite_sdk/category'
25
+ require 'eventbrite_sdk/discount'
25
26
  require 'eventbrite_sdk/event'
26
27
  require 'eventbrite_sdk/media'
27
28
  require 'eventbrite_sdk/order'
29
+ require 'eventbrite_sdk/organization'
28
30
  require 'eventbrite_sdk/organizer'
29
31
  require 'eventbrite_sdk/report'
30
32
  require 'eventbrite_sdk/subcategory'
@@ -33,6 +35,7 @@ require 'eventbrite_sdk/ticket_group'
33
35
  require 'eventbrite_sdk/user'
34
36
  require 'eventbrite_sdk/venue'
35
37
  require 'eventbrite_sdk/webhook'
38
+ require 'eventbrite_sdk/organization_entities' # depends on Discount, Event, Venue
36
39
 
37
40
  module EventbriteSDK
38
41
  BASE = "https://www.eventbriteapi.com/v#{VERSION.split('.').first}".freeze
@@ -0,0 +1,78 @@
1
+ module EventbriteSDK
2
+ class Discount < Resource
3
+ ACCESS_HIDDEN_TICKETS = 'access'.freeze # unlock access to hidden tickets
4
+ ACCESS_HOLDS = 'hold'.freeze # unlock access to HoldClasses (reserved seating)
5
+ PROTECTED_DISCOUNT = 'coded'.freeze # unlock a discount
6
+ PUBLIC_DISCOUNT = 'public'.freeze # a publicly available discount
7
+
8
+ TYPES = [
9
+ ACCESS_HIDDEN_TICKETS,
10
+ ACCESS_HOLDS,
11
+ PROTECTED_DISCOUNT,
12
+ PUBLIC_DISCOUNT
13
+ ].freeze
14
+
15
+ resource_path 'discounts/:id'
16
+
17
+ belongs_to :event, object_class: 'Event'
18
+ belongs_to :ticket_group, object_class: 'TicketGroup'
19
+
20
+ attributes_prefix 'discount'
21
+
22
+ schema_definition do
23
+ string 'amount_off' # Fixed reduction amount as a decimal - "12.99".
24
+ string 'code' # required: Code used to activate discount.
25
+ string 'discount_type' # required: Type of discount. (Valid choices are: access, hold, coded, or public)
26
+ string 'end_date' # Allow use until this date.
27
+ integer 'end_date_relative' # Allow use until this number of seconds before the event starts.
28
+ string 'event_id' # ID of the event. Only used for single event discounts.
29
+ string 'hold_ids' # IDs of holds this discount can unlock
30
+ string 'percent_off' # Percentage reduction. Supports 2 digit decimal precision - "50" or "50.01".
31
+ integer 'quantity_available' # Number of discount uses.
32
+ string 'start_date' # Allow use from this date.
33
+ integer 'start_date_relative' # Allow use from this number of seconds before the event starts.
34
+ string 'ticket_group_id' # ID of the ticket group
35
+ string 'ticket_ids' # IDs of tickets to limit discount to
36
+ end
37
+
38
+
39
+ def access_hidden_tickets?
40
+ discount_type == ACCESS_HIDDEN_TICKETS
41
+ end
42
+
43
+ def access_holds?
44
+ discount_type == ACCESS_HOLDS
45
+ end
46
+
47
+ def discount?
48
+ protected_discount? || public_discount?
49
+ end
50
+
51
+ def protected_discount?
52
+ discount_type == PROTECTED_DISCOUNT
53
+ end
54
+
55
+ def public_discount?
56
+ discount_type == PUBLIC_DISCOUNT
57
+ end
58
+
59
+ #
60
+ # Ticket groups that are auto created for all tickets of an org can NOT be
61
+ # accessed through the API, even though the ticket_group_id is present.
62
+ #
63
+ # We expand ticket_group on all queries - so ticket_group_id exists
64
+ # for that group, and ticket_group is present with a nil value in the data.
65
+ # In that case, when you call Discount#ticket_group the resource would
66
+ # attempt to retrieve it... and the API would return a 404 response. Bad.
67
+ #
68
+ # You can't use Discount#ticket_group unless it's safe to do so.
69
+ # You have to check the attribute data to verify that calling #ticket_group
70
+ # will not try to retrieve a "forbidden" group and raise an exception
71
+ #
72
+ def ticket_group_accessible?
73
+ !ticket_group_id.nil? &&
74
+ attrs.respond_to?(:ticket_group) &&
75
+ !attrs['ticket_group'].nil?
76
+ end
77
+ end
78
+ end
@@ -57,15 +57,6 @@ module EventbriteSDK
57
57
  string 'resource_uri', read_only: true
58
58
  end
59
59
 
60
- def self.search(params)
61
- ResourceList.new(
62
- url_base: 'events/search',
63
- object_class: self,
64
- key: 'events',
65
- query: params
66
- )
67
- end
68
-
69
60
  def list!
70
61
  unless listed
71
62
  assign_attributes('listed' => true)
@@ -2,12 +2,6 @@ module EventbriteSDK
2
2
  class Order < Resource
3
3
  resource_path 'orders/:id'
4
4
 
5
- # Defines order#resend_confirmation_email and order#refund
6
- #
7
- # When an event has an id the POST is made, otherwise we return false
8
- # POSTS to order/:id/(resend_confirmation_email|refunds)
9
- define_api_actions :resend_confirmation_email, refund: :refunds
10
-
11
5
  has_many :attendees, object_class: 'Attendee'
12
6
  belongs_to :event, object_class: 'Event'
13
7
 
@@ -0,0 +1,131 @@
1
+ module EventbriteSDK
2
+ class Organization < Resource
3
+ ALL_DISCOUNTS = 'user',
4
+ SINGLE_EVENT_DISCOUNTS = 'event',
5
+ MULTI_EVENT_DISCOUNTS = 'multi_events',
6
+
7
+ # Event search "order_by" values
8
+ CREATED_NEWEST_FIRST = 'created_desc',
9
+ CREATED_OLDEST_FIRST = 'created_asc',
10
+ START_NEWEST_FIRST = 'start_desc',
11
+ START_OLDEST_FIRST = 'start_asc',
12
+
13
+ # Event search "status" values
14
+ # ALL will cause the search to return any of the following:
15
+ # canceled
16
+ # ended
17
+ # finalized
18
+ # incomplete
19
+ # live
20
+ # started
21
+ # payout_issued
22
+ ALL = 'all',
23
+ CANCELED = 'canceled',
24
+ DRAFT = 'draft',
25
+ # ENDED will return any of the following:
26
+ # ended
27
+ # finalized
28
+ # payout_issued
29
+ ENDED = 'ended',
30
+ LIVE = 'live',
31
+ STARTED = 'started'
32
+
33
+ # Search order values
34
+ SEARCH_ORDERS_STATUS_ALL = 'all_not_deleted'
35
+ SEARCH_ORDERS_STATUS_ACTIVE = 'active'
36
+ SEARCH_ORDERS_STATUS_INACTIVE = 'inactive'
37
+ SEARCH_ORDERS_STATUS_ACTIVE_AND_INACTIVE = 'both'
38
+
39
+ resource_path 'organizations/:id'
40
+
41
+ has_many :discounts, object_class: 'OrgDiscount'
42
+ has_many :organizers, object_class: 'Organizer', key: :organizers
43
+ # Previously :owned_event_orders
44
+ has_many :orders, object_class: 'Order', key: :orders
45
+ # Previously :owned_events
46
+ has_many :events, object_class: 'OrgEvent', key: :events
47
+ has_many :ticket_classes, object_class: 'TicketClass'
48
+ has_many :ticket_groups, object_class: 'TicketGroup'
49
+ # Query for all events, ordered by start date in ascending order.
50
+ #
51
+ # order_by: Change the order they are returned. Supports:
52
+ # created_asc
53
+ # created_desc
54
+ # start_asc
55
+ # start_desc
56
+ #
57
+ # status: Status(es) of events you want. Supports single values or CSV:
58
+ # all - all available statuses. Includes:
59
+ # canceled - only canceled.
60
+ # draft - only draft
61
+ # ended - all ended statuses. Includes:
62
+ # live - only live
63
+ # started - only started
64
+ #
65
+ def upcoming_events(order_by: self.class::START_OLDEST_FIRST,
66
+ status: self.class::ALL)
67
+ EventbriteSDK::ResourceList.new(
68
+ url_base: "#{path}/events",
69
+ object_class: EventbriteSDK::Event,
70
+ key: 'events',
71
+ query: {
72
+ order_by: order_by,
73
+ status: status
74
+ }
75
+ )
76
+ end
77
+
78
+ #
79
+ # Retrieve all orders for the organization based on given search criteria.
80
+ # changed_since - datetime - orders changed on or after the given datetime.
81
+ # You can also pass a string formatted as %FT%TZ
82
+ # exclude_emails - string array - do not include orders for these emails
83
+ # only_emails - string array - only include orders for these emails
84
+ # status - One of: all, active, inactive, active_and_inactive
85
+ #
86
+ # This method does no parameter validation. If you pass an unsupported status
87
+ # or an invalid format changed_since you'll definitely hear about if from
88
+ # the endpoint.
89
+ #
90
+ def search_orders(params={})
91
+ coerce_search_orders_params(params)
92
+
93
+ EventbriteSDK::ResourceList.new(
94
+ url_base: "#{path}/orders",
95
+ object_class: EventbriteSDK::Order,
96
+ key: :orders,
97
+ query: params
98
+ )
99
+ end
100
+
101
+ # NOTE Shim to normalize API between a user/organization
102
+ def owned_events
103
+ events
104
+ end
105
+
106
+ private
107
+
108
+ def coerce_search_orders_params(params)
109
+ format_changed_since(params)
110
+ format_emails(params)
111
+
112
+ params
113
+ end
114
+
115
+ def format_changed_since(params)
116
+ value = params[:changed_since]
117
+
118
+ if value and value.respond_to?(:strftime)
119
+ params[:changed_since] = value.strftime('%FT%TZ')
120
+ end
121
+ end
122
+
123
+ def format_emails(params)
124
+ for key in %i(exclude_emails only_emails)
125
+ if params[key] and params[key].any?
126
+ params[key] = params[key].join(',')
127
+ end
128
+ end
129
+ end
130
+ end
131
+ end
@@ -0,0 +1,16 @@
1
+ class EventbriteSDK::OrgDiscount < EventbriteSDK::Discount
2
+ resource_path create: 'organizations/:organization_id/discounts',
3
+ update: 'discounts/:id'
4
+ end
5
+
6
+ class EventbriteSDK::OrgVenue < EventbriteSDK::Venue
7
+ resource_path create: 'organizations/:organization_id/venues',
8
+ update: 'venues/:id'
9
+ end
10
+
11
+ class EventbriteSDK::OrgEvent < EventbriteSDK::Event
12
+ resource_path create: 'organizations/:organization_id/events',
13
+ update: 'events/:id'
14
+
15
+ belongs_to :venue, object_class: 'OrgVenue'
16
+ end
@@ -1,18 +1,10 @@
1
1
  module EventbriteSDK
2
2
  class User < Resource
3
- # Defines user#verify and user#unverify
4
- #
5
- # An user logged using Eventbrite we should generate a verification action
6
- # NOTE: only selected users can verify/unverify other users.
7
- # POSTS to users/:id/(verify|unverify)
8
- define_api_actions :verify, :unverify
9
-
10
3
  resource_path 'users/:id'
11
4
 
12
- has_many :organizers, object_class: 'Organizer', key: :organizers
5
+ # NOTE: This name is pretty legacy. We should consider renaming
6
+ # to "orders" to normalize things.
13
7
  has_many :owned_event_orders, object_class: 'Order', key: :orders
14
- has_many :owned_events, object_class: 'Event', key: :events
15
- has_many :ticket_groups, object_class: 'TicketGroup'
16
8
 
17
9
  schema_definition do
18
10
  string 'name'
@@ -4,19 +4,22 @@ module EventbriteSDK
4
4
 
5
5
  attributes_prefix 'venue'
6
6
 
7
- belongs_to :organizer, object_class: 'Organizer'
8
-
9
7
  schema_definition do
10
- string 'name'
11
- string 'address.latitude'
12
- string 'address.longitude'
13
- string 'organizer_id'
14
8
  string 'address.address_1'
15
9
  string 'address.address_2'
16
10
  string 'address.city'
17
- string 'address.region'
18
- string 'address.postal_code'
19
11
  string 'address.country'
12
+ string 'address.latitude' # decimal, passed as string.
13
+ string 'address.localized_address_display'
14
+ string 'address.localized_area_display'
15
+ string 'address.longitude' # decimal, passed as string.
16
+ string 'address.postal_code'
17
+ string 'address.region'
18
+ string 'age_restriction'
19
+ string 'capacity'
20
+ string 'latitude'
21
+ string 'longitude'
22
+ string 'name'
20
23
  end
21
24
  end
22
25
  end
@@ -1,5 +1,5 @@
1
1
  module EventbriteSDK
2
2
  # Major should always line up with the major point release of the public API
3
3
  # v3 => 3.x.x
4
- VERSION = '3.4.0'.freeze
4
+ VERSION = '3.6.0'.freeze
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventbrite_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.0
4
+ version: 3.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vinnie Franco
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2018-11-01 00:00:00.000000000 Z
13
+ date: 2020-04-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rest-client
@@ -30,30 +30,30 @@ dependencies:
30
30
  name: bundler
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
- - - "~>"
33
+ - - ">="
34
34
  - !ruby/object:Gem::Version
35
- version: '1.12'
35
+ version: '2.1'
36
36
  type: :development
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
- - - "~>"
40
+ - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: '1.12'
42
+ version: '2.1'
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: rake
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - "~>"
47
+ - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: '10.0'
49
+ version: 12.3.3
50
50
  type: :development
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
- - - "~>"
54
+ - - ">="
55
55
  - !ruby/object:Gem::Version
56
- version: '10.0'
56
+ version: 12.3.3
57
57
  - !ruby/object:Gem::Dependency
58
58
  name: rspec
59
59
  requirement: !ruby/object:Gem::Requirement
@@ -121,12 +121,15 @@ files:
121
121
  - lib/eventbrite_sdk/attendee.rb
122
122
  - lib/eventbrite_sdk/blank_resource_list.rb
123
123
  - lib/eventbrite_sdk/category.rb
124
+ - lib/eventbrite_sdk/discount.rb
124
125
  - lib/eventbrite_sdk/error_types.rb
125
126
  - lib/eventbrite_sdk/event.rb
126
127
  - lib/eventbrite_sdk/exceptions.rb
127
128
  - lib/eventbrite_sdk/lists/owned_event_orders_list.rb
128
129
  - lib/eventbrite_sdk/media.rb
129
130
  - lib/eventbrite_sdk/order.rb
131
+ - lib/eventbrite_sdk/organization.rb
132
+ - lib/eventbrite_sdk/organization_entities.rb
130
133
  - lib/eventbrite_sdk/organizer.rb
131
134
  - lib/eventbrite_sdk/report.rb
132
135
  - lib/eventbrite_sdk/resource.rb