Class: Toptranslation::Resource::Order
- Inherits:
-
Object
- Object
- Toptranslation::Resource::Order
- Defined in:
- lib/toptranslation/resource/order.rb
Instance Attribute Summary collapse
-
#comment ⇒ Object
Returns the value of attribute comment.
-
#coupon_code ⇒ Object
Returns the value of attribute coupon_code.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#creator_hash ⇒ Object
readonly
Returns the value of attribute creator_hash.
-
#desired_delivery_date ⇒ Object
Returns the value of attribute desired_delivery_date.
-
#estimated_delivery_date ⇒ Object
readonly
Returns the value of attribute estimated_delivery_date.
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
-
#name ⇒ Object
Returns the value of attribute name.
-
#order_number ⇒ Object
readonly
Returns the value of attribute order_number.
-
#ordered_at ⇒ Object
readonly
Returns the value of attribute ordered_at.
-
#progress ⇒ Object
readonly
Returns the value of attribute progress.
-
#quote_required ⇒ Object
Returns the value of attribute quote_required.
-
#reference ⇒ Object
Returns the value of attribute reference.
-
#requested_at ⇒ Object
readonly
Returns the value of attribute requested_at.
-
#service_level ⇒ Object
Returns the value of attribute service_level.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
- #add_document(document_store_id, document_token, source_locale_code, target_locale_codes) ⇒ Object
- #creator ⇒ Object
- #documents ⇒ Object
-
#initialize(connection, options = {}) ⇒ Order
constructor
A new instance of Order.
- #quotes ⇒ Object
- #request ⇒ Object
- #save ⇒ Object
- #translations ⇒ Object
- #upload_document(filepath, source_locale_code, target_locale_codes) ⇒ Object
Constructor Details
#initialize(connection, options = {}) ⇒ Order
Returns a new instance of Order.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/toptranslation/resource/order.rb', line 8 def initialize(connection, = {}) @connection = connection = @name = [:name] @reference = [:reference] @comment = [:comment] @coupon_code = [:coupon_code] @service_level = [:service_level] @desired_delivery_date = [:desired_delivery_date] @quote_required = [:quote_required] @delivery_date = nil @identifier = nil update_from_response() end |
Instance Attribute Details
#comment ⇒ Object
Returns the value of attribute comment.
6 7 8 |
# File 'lib/toptranslation/resource/order.rb', line 6 def comment @comment end |
#coupon_code ⇒ Object
Returns the value of attribute coupon_code.
6 7 8 |
# File 'lib/toptranslation/resource/order.rb', line 6 def coupon_code @coupon_code end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
3 4 5 |
# File 'lib/toptranslation/resource/order.rb', line 3 def created_at @created_at end |
#creator_hash ⇒ Object (readonly)
Returns the value of attribute creator_hash.
3 4 5 |
# File 'lib/toptranslation/resource/order.rb', line 3 def creator_hash @creator_hash end |
#desired_delivery_date ⇒ Object
Returns the value of attribute desired_delivery_date.
6 7 8 |
# File 'lib/toptranslation/resource/order.rb', line 6 def desired_delivery_date @desired_delivery_date end |
#estimated_delivery_date ⇒ Object (readonly)
Returns the value of attribute estimated_delivery_date.
3 4 5 |
# File 'lib/toptranslation/resource/order.rb', line 3 def estimated_delivery_date @estimated_delivery_date end |
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
3 4 5 |
# File 'lib/toptranslation/resource/order.rb', line 3 def identifier @identifier end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/toptranslation/resource/order.rb', line 6 def name @name end |
#order_number ⇒ Object (readonly)
Returns the value of attribute order_number.
3 4 5 |
# File 'lib/toptranslation/resource/order.rb', line 3 def order_number @order_number end |
#ordered_at ⇒ Object (readonly)
Returns the value of attribute ordered_at.
3 4 5 |
# File 'lib/toptranslation/resource/order.rb', line 3 def ordered_at @ordered_at end |
#progress ⇒ Object (readonly)
Returns the value of attribute progress.
3 4 5 |
# File 'lib/toptranslation/resource/order.rb', line 3 def progress @progress end |
#quote_required ⇒ Object
Returns the value of attribute quote_required.
6 7 8 |
# File 'lib/toptranslation/resource/order.rb', line 6 def quote_required @quote_required end |
#reference ⇒ Object
Returns the value of attribute reference.
6 7 8 |
# File 'lib/toptranslation/resource/order.rb', line 6 def reference @reference end |
#requested_at ⇒ Object (readonly)
Returns the value of attribute requested_at.
3 4 5 |
# File 'lib/toptranslation/resource/order.rb', line 3 def requested_at @requested_at end |
#service_level ⇒ Object
Returns the value of attribute service_level.
6 7 8 |
# File 'lib/toptranslation/resource/order.rb', line 6 def service_level @service_level end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
3 4 5 |
# File 'lib/toptranslation/resource/order.rb', line 3 def state @state end |
Instance Method Details
#add_document(document_store_id, document_token, source_locale_code, target_locale_codes) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/toptranslation/resource/order.rb', line 24 def add_document(document_store_id, document_token, source_locale_code, target_locale_codes) response = @connection.post("/orders/#{@identifier}/documents", document_store_id: document_store_id, document_token: document_token, source_locale_code: source_locale_code, target_locale_codes: target_locale_codes, version: 2) Document.new(@connection, response) end |
#creator ⇒ Object
53 54 55 |
# File 'lib/toptranslation/resource/order.rb', line 53 def creator @creator ||= User.new(@connection, ['creator']) end |
#documents ⇒ Object
41 42 43 |
# File 'lib/toptranslation/resource/order.rb', line 41 def documents @connection.get("/orders/#{@identifier}/documents", version: 2) end |
#quotes ⇒ Object
45 46 47 |
# File 'lib/toptranslation/resource/order.rb', line 45 def quotes @quotes ||= ['quotes'].map { |quote| Quote.new(@connection, quote) } end |
#request ⇒ Object
62 63 64 65 |
# File 'lib/toptranslation/resource/order.rb', line 62 def request response = @connection.patch("/orders/#{@identifier}/request", version: 2) update_and_return_from_response(response) end |
#save ⇒ Object
57 58 59 60 |
# File 'lib/toptranslation/resource/order.rb', line 57 def save response = @identifier ? update_remote_order : create_remote_order update_and_return_from_response(response) end |
#translations ⇒ Object
49 50 51 |
# File 'lib/toptranslation/resource/order.rb', line 49 def translations TranslationList.new(@connection, order_identifier: @identifier) end |
#upload_document(filepath, source_locale_code, target_locale_codes) ⇒ Object
35 36 37 38 39 |
# File 'lib/toptranslation/resource/order.rb', line 35 def upload_document(filepath, source_locale_code, target_locale_codes) upload = Upload.new(@connection).upload(filepath) add_document(upload.document_store_id, upload.document_token, source_locale_code, target_locale_codes) end |