Class: TranslationCms::Api::Customers::Order

Inherits:
Order
  • Object
show all
Extended by:
HstoreTranslate::Translates
Defined in:
lib/translation_cms/api/customers/order.rb

Constant Summary

Constants inherited from Order

Order::AVAILABLE_STATES, Order::BLOCK_EXTRAS_STATES, Order::CANCELED_STATES, Order::COMPLETED_STATES, Order::PENDING_STATES, Order::PROCESSING_STATES, Order::REFUNDED_STATES, Order::REF_MATERIALS_MANAGE_STATES

Instance Method Summary collapse

Methods inherited from Order

#deafult_features, #extra_features, #not_paid?, #state_title, #target_title, #urgency

Methods included from HumanizeFields

#human_name, #human_value

Methods inherited from Base

all!, custom_scope!, default_attributes, destroy, dummy_resource!, #method_missing_with_translations_will_change, parsed!, path_with_custom_scope, resource_type!, update

Instance Method Details

#any_completed_atObject



76
77
78
# File 'lib/translation_cms/api/customers/order.rb', line 76

def any_completed_at
  parsed_completed_at || parsed_customer_due_date
end

#base_attributesObject



20
21
22
23
24
25
# File 'lib/translation_cms/api/customers/order.rb', line 20

def base_attributes
  attributes.to_json(only: [:service_id, :category_id, :industry_expertise_id, :certificate_id,
                            :language_from_id, :languages_to_ids, :number, :state, :customer_due_date,
                            :order_package_id, :waiting_payment_token, :urgency_type_id,
                            :total_words_count, :waiting_payment_amount, :total_cost])
end

#feedback_paramsObject



68
69
70
71
72
73
74
# File 'lib/translation_cms/api/customers/order.rb', line 68

def feedback_params
  if defined?(relationships.feedbacks) && feedbacks.present?
    feedbacks.first.attributes.to_json(only: [:id, :rate, :content, :updated_at])
  else
    'null'
  end
end

#notificationObject



61
62
63
64
65
66
# File 'lib/translation_cms/api/customers/order.rb', line 61

def notification
  return nil if notifications.blank?

  notification_type ||= notifications.detect { |type| type.order_completed? }
  notification_type ||= notifications.last
end

#notificationsObject



53
54
55
56
57
58
59
# File 'lib/translation_cms/api/customers/order.rb', line 53

def notifications
  return [] if notifications_type_ids.blank?

  @notifications ||= notifications_type_ids.map do |type_id|
    OrderNotificationType.find_by(id: type_id)
  end.reject(&:nil?)
end