Class: Gonebusy::CreateBookingBody

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/gonebusy/models/create_booking_body.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(service_id = nil, date = nil, time = nil, user_id = nil, resource_id = nil, duration = nil, end_date = nil, recurs_by = nil, frequency = nil, days = nil, occurrence = nil, date_recurs_by = nil, name = nil, description = nil) ⇒ CreateBookingBody

Returns a new instance of CreateBookingBody.



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/gonebusy/models/create_booking_body.rb', line 83

def initialize(service_id = nil,
               date = nil,
               time = nil,
               user_id = nil,
               resource_id = nil,
               duration = nil,
               end_date = nil,
               recurs_by = nil,
               frequency = nil,
               days = nil,
               occurrence = nil,
               date_recurs_by = nil,
               name = nil,
               description = nil)
  @service_id = service_id
  @date = date
  @time = time
  @user_id = user_id
  @resource_id = resource_id
  @duration = duration
  @end_date = end_date
  @recurs_by = recurs_by
  @frequency = frequency
  @days = days
  @occurrence = occurrence
  @date_recurs_by = date_recurs_by
  @name = name
  @description = description
end

Instance Attribute Details

#dateDate

Desired date of booking. Several formats are supported: “2014-10-31”, “October 31, 2014”

Returns:

  • (Date)


11
12
13
# File 'lib/gonebusy/models/create_booking_body.rb', line 11

def date
  @date
end

#date_recurs_byDateRecursByEnum

Required only when :recurs_by is ‘monthly’ or ‘yearly’ to differentiate between exact date or ‘day in month/year’. See Recurring Booking examples.

Returns:



51
52
53
# File 'lib/gonebusy/models/create_booking_body.rb', line 51

def date_recurs_by
  @date_recurs_by
end

#daysString

List of comma-separated days of the week this Booking falls on. Useful for recurring Bookings. If provided, at least one must be specified.

Returns:



43
44
45
# File 'lib/gonebusy/models/create_booking_body.rb', line 43

def days
  @days
end

#descriptionString

Optional description for Booking.

Returns:



59
60
61
# File 'lib/gonebusy/models/create_booking_body.rb', line 59

def description
  @description
end

#durationInteger

Length of time, in minutes, for the desired booking - if Service allows requesting a variable amount of time

Returns:

  • (Integer)


27
28
29
# File 'lib/gonebusy/models/create_booking_body.rb', line 27

def duration
  @duration
end

#end_dateDate

Optional end date if a recurring booking - i.e, :recurs_by other than :once. If recurring, leave blank for infinite booking. Several formats are supported: ‘2014-10-31’, ‘October 31, 2014’.

Returns:

  • (Date)


31
32
33
# File 'lib/gonebusy/models/create_booking_body.rb', line 31

def end_date
  @end_date
end

#frequencyFrequencyEnum

Optional frequency of recurrence as specified by :recurs_by. E.g, :single, :every, :every_other, etc. If not provided, assumed to be :once

Returns:



39
40
41
# File 'lib/gonebusy/models/create_booking_body.rb', line 39

def frequency
  @frequency
end

#nameString

Optional name for Booking, otherwise will take name of Service.

Returns:



55
56
57
# File 'lib/gonebusy/models/create_booking_body.rb', line 55

def name
  @name
end

#occurrenceOccurrenceEnum

Optional occurrence of frequency. E.g, :first, :2nd, :last, :2nd_to_last, etc. If not provided, assumed to be :every

Returns:



47
48
49
# File 'lib/gonebusy/models/create_booking_body.rb', line 47

def occurrence
  @occurrence
end

#recurs_byRecursByEnum

One of the possible recurrence values. If not provided, assumed to be :once to indicate a single Booking.

Returns:



35
36
37
# File 'lib/gonebusy/models/create_booking_body.rb', line 35

def recurs_by
  @recurs_by
end

#resource_idInteger

ID of a Resource to be booked. If not provided, the first available Resource will be booked.

Returns:

  • (Integer)


23
24
25
# File 'lib/gonebusy/models/create_booking_body.rb', line 23

def resource_id
  @resource_id
end

#service_idInteger

ID of Service being booked

Returns:

  • (Integer)


7
8
9
# File 'lib/gonebusy/models/create_booking_body.rb', line 7

def service_id
  @service_id
end

#timeString

Desired time of booking. Several formats are supported: ‘9am’, ‘09:00’, ‘9:00’, ‘0900’

Returns:



15
16
17
# File 'lib/gonebusy/models/create_booking_body.rb', line 15

def time
  @time
end

#user_idInteger

Create a booking for this User Id. You must be authorized to manage this User Id.

Returns:

  • (Integer)


19
20
21
# File 'lib/gonebusy/models/create_booking_body.rb', line 19

def user_id
  @user_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/gonebusy/models/create_booking_body.rb', line 114

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash
  service_id = hash['service_id']
  date = hash['date']
  time = hash['time']
  user_id = hash['user_id']
  resource_id = hash['resource_id']
  duration = hash['duration']
  end_date = hash['end_date']
  recurs_by = hash['recurs_by']
  frequency = hash['frequency']
  days = hash['days']
  occurrence = hash['occurrence']
  date_recurs_by = hash['date_recurs_by']
  name = hash['name']
  description = hash['description']

  # Create object from extracted values
  CreateBookingBody.new(service_id,
                        date,
                        time,
                        user_id,
                        resource_id,
                        duration,
                        end_date,
                        recurs_by,
                        frequency,
                        days,
                        occurrence,
                        date_recurs_by,
                        name,
                        description)
end

.namesObject

A mapping from model property names to API property names



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/gonebusy/models/create_booking_body.rb', line 62

def self.names
  if @_hash.nil?
    @_hash = {}
    @_hash["service_id"] = "service_id"
    @_hash["date"] = "date"
    @_hash["time"] = "time"
    @_hash["user_id"] = "user_id"
    @_hash["resource_id"] = "resource_id"
    @_hash["duration"] = "duration"
    @_hash["end_date"] = "end_date"
    @_hash["recurs_by"] = "recurs_by"
    @_hash["frequency"] = "frequency"
    @_hash["days"] = "days"
    @_hash["occurrence"] = "occurrence"
    @_hash["date_recurs_by"] = "date_recurs_by"
    @_hash["name"] = "name"
    @_hash["description"] = "description"
  end
  @_hash
end