Class: Rev::Order

Inherits:
ApiSerializable show all
Defined in:
lib/rev-api/models/order.rb

Overview

Represents a Caption or Transcription order. Should have CaptionInfo or TranscriptionInfo, list of comments and attachments. Attributes names reflect API exposed names, but occasional hyphens are replaced with underscores

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ApiSerializable

#to_hash, #to_json

Constructor Details

#initialize(fields) ⇒ Order

Returns a new instance of Order.

Parameters:

  • fields (Hash)

    hash of order fields parsed from JSON API response



14
15
16
17
18
19
20
# File 'lib/rev-api/models/order.rb', line 14

def initialize(fields)
  super fields
  @attachments = fields['attachments'].map { |attachment_fields| Attachment.new(attachment_fields) }
  @comments = fields['comments'].map { |comment_fields| Comment.new(comment_fields) }
  @transcription = TranscriptionInfo.new(fields['transcription']) if fields['transcription']
  @caption = CaptionInfo.new(fields['caption']) if fields['caption']
end

Instance Attribute Details

#attachmentsObject (readonly)

Returns the value of attribute attachments.



10
11
12
# File 'lib/rev-api/models/order.rb', line 10

def attachments
  @attachments
end

#captionObject (readonly)

Returns the value of attribute caption.



10
11
12
# File 'lib/rev-api/models/order.rb', line 10

def caption
  @caption
end

#client_refObject (readonly)

Returns the value of attribute client_ref.



10
11
12
# File 'lib/rev-api/models/order.rb', line 10

def client_ref
  @client_ref
end

#commentsObject (readonly)

Returns the value of attribute comments.



10
11
12
# File 'lib/rev-api/models/order.rb', line 10

def comments
  @comments
end

#order_numberObject (readonly)

Returns the value of attribute order_number.



10
11
12
# File 'lib/rev-api/models/order.rb', line 10

def order_number
  @order_number
end

#priceObject (readonly)

Returns the value of attribute price.



10
11
12
# File 'lib/rev-api/models/order.rb', line 10

def price
  @price
end

#statusObject (readonly)

Returns the value of attribute status.



10
11
12
# File 'lib/rev-api/models/order.rb', line 10

def status
  @status
end

#transcriptionObject (readonly)

Returns the value of attribute transcription.



10
11
12
# File 'lib/rev-api/models/order.rb', line 10

def transcription
  @transcription
end

Instance Method Details

#captionsArray of Attachment

Returns with the kind of “caption”.

Returns:

  • (Array of Attachment)

    with the kind of “caption”



28
29
30
# File 'lib/rev-api/models/order.rb', line 28

def captions
  @attachments.select { |a| a.kind == Attachment::KINDS[:caption] }
end

#sourcesArray of Attachment

Returns with the kind of “sources”.

Returns:

  • (Array of Attachment)

    with the kind of “sources”



33
34
35
# File 'lib/rev-api/models/order.rb', line 33

def sources
  @attachments.select { |a| a.kind == Attachment::KINDS[:media]}
end

#transcriptsArray of Attachment

Returns with the kind of “transcript”.

Returns:

  • (Array of Attachment)

    with the kind of “transcript”



23
24
25
# File 'lib/rev-api/models/order.rb', line 23

def transcripts
  @attachments.select { |a| a.kind == Attachment::KINDS[:transcript]}
end