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(date = nil, service_id = nil, time = nil, duration = nil, resource_id = nil, user_id = nil) ⇒ CreateBookingBody

Returns a new instance of CreateBookingBody.



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/gonebusy/models/create_booking_body.rb', line 43

def initialize(date = nil,
               service_id = nil,
               time = nil,
               duration = nil,
               resource_id = nil,
               user_id = nil)
  @date = date
  @service_id = service_id
  @time = time
  @duration = duration
  @resource_id = resource_id
  @user_id = user_id
end

Instance Attribute Details

#dateString

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

Returns:



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

def date
  @date
end

#durationInteger

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

Returns:

  • (Integer)


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

def duration
  @duration
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)


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

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)


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

def user_id
  @user_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash



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

def self.from_hash(hash)
  if hash == nil
    nil
  else
    # Extract variables from the hash

    date = hash["date"]
    service_id = hash["service_id"]
    time = hash["time"]
    duration = hash["duration"]
    resource_id = hash["resource_id"]
    user_id = hash["user_id"]

    # Create object from extracted values

    CreateBookingBody.new(date,
                          service_id,
                          time,
                          duration,
                          resource_id,
                          user_id)
  end
end

.namesObject

A mapping from model property names to API property names



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/gonebusy/models/create_booking_body.rb', line 30

def self.names
  if @hash.nil?
    @hash = {}
    @hash["date"] = "date"
    @hash["service_id"] = "service_id"
    @hash["time"] = "time"
    @hash["duration"] = "duration"
    @hash["resource_id"] = "resource_id"
    @hash["user_id"] = "user_id"
  end
  @hash
end