Skip to content

Instantly share code, notes, and snippets.

@hygull
Last active June 22, 2019 05:12
Show Gist options
  • Save hygull/987d12b0861abc94f0bb6f65043aafff to your computer and use it in GitHub Desktop.
Save hygull/987d12b0861abc94f0bb6f65043aafff to your computer and use it in GitHub Desktop.
Roserocket get fields for ORDER, COMMODITY, CUSTOMER

Get entity fields - Roserocket (Customer, Order, Commodity)

// --- Date: 20 June 2019 ---
function get_customer_fields() {
    let customer_fields = [
        "address_1",
        "address_2",
        "billing_contact_email",
        "billing_contact_name",
        "billing_contact_phone",
        "bus_hours_fri_end_at",
        "bus_hours_fri_start_at",
        "bus_hours_mon_end_at",
        "bus_hours_mon_start_at",
        "bus_hours_sat_end_at",
        "bus_hours_sat_start_at",
        "bus_hours_sun_end_at",
        "bus_hours_sun_start_at",
        "bus_hours_thu_end_at",
        "bus_hours_thu_start_at",
        "bus_hours_tue_end_at",
        "bus_hours_tue_start_at",
        "bus_hours_wed_end_at",
        "bus_hours_wed_start_at",
        "ca_us_custom_broker_contact_name",
        "ca_us_custom_broker_email",
        "ca_us_custom_broker_name",
        "ca_us_custom_broker_notes",
        "ca_us_custom_broker_phone",
        "ca_us_custom_broker_phone_ext",
        "city",
        "country",
        "country",
        "credit_balance",
        "credit_limit",
        "currency_id",
        "default_billing_option",
        "default_dim_type",
        "default_order_notes",
        "dispatch_contact_email",
        "dispatch_contact_name",
        "dispatch_contact_phone",
        "email",
        "external_id",
        "fax",
        "is_active",
        "latitude",
        "longitude",
        "management_contact_email",
        "management_contact_name",
        "management_contact_phone",
        "name",
        "other_contact_email",
        "other_contact_name",
        "other_contact_phone",
        "phone",
        "phone_ext",
        "postal",
        "sales_contact_email",
        "sales_contact_name",
        "sales_contact_phone",
        "short_code",
        "state",
        "suite",
        "us_ca_custom_broker_contact_name",
        "us_ca_custom_broker_email",
        "us_ca_custom_broker_name",
        "us_ca_custom_broker_notes",
        "us_ca_custom_broker_phone",
        "us_ca_custom_broker_phone_ext"
    ]

    return customer_fields
}

function get_order_fields() {
    let order_fields = [
        "commodity_type",
        "commodity_type_other",
        "description",
        "feet",
        "freight_class",
        "height",
        "id",
        "is_stackable",
        "length",
        "measurement_unit",
        "nmfc",
        "pieces",
        "quantity",
        "sku",
        "volume",
        "weight",
        "weight_unit",
        "width"
    ]

    return order_fields
}


function get_commodity_fields() {
    let commodity_fields = [
        "accessorials",
        "billing",
        "billing_option",
        "commodities",
        "custom_broker",
        "customer",
        "declared_value",
        "declared_value_currency",
        "default_measurement_unit_id",
        "default_weight_unit_id",
        "delivery_appt_end_at",
        "delivery_appt_start_at",
        "delivery_end_at",
        "delivery_start_at",
        "destination",
        "dim_type",
        "external_id",
        "id",
        "notes",
        "origin",
        "pickup_appt_end_at",
        "pickup_appt_start_at",
        "pickup_end_at",
        "pickup_start_at",
        "po_num",
        "public_id",
        "ref_num",
        "sequence_id",
        "status",
        "tender_id",
        "tender_num"
    ]

    return commodity_fields
}


function get_entity_fields(entity_type) {
    let entity = {
        'order': get_order_fields,
        'customer': get_customer_fields,
        'commodity': get_commodity_fields
    }

    let entity_fields = entity[entity_type.toLowerCase()]()
    return entity_fields
}


function test() {
    console.log(get_entity_fields('order'))
    console.log('\n')
    
    console.log(get_entity_fields('customer'))
    console.log('\n')
    
    console.log(get_entity_fields('commodity'))
    console.log('\n')
}

test()

Output

[ 'commodity_type',
  'commodity_type_other',
  'description',
  'feet',
  'freight_class',
  'height',
  'id',
  'is_stackable',
  'length',
  'measurement_unit',
  'nmfc',
  'pieces',
  'quantity',
  'sku',
  'volume',
  'weight',
  'weight_unit',
  'width' ]
  
[ 'address_1',
  'address_2',
  'billing_contact_email',
  'billing_contact_name',
  'billing_contact_phone',
  'bus_hours_fri_end_at',
  'bus_hours_fri_start_at',
  'bus_hours_mon_end_at',
  'bus_hours_mon_start_at',
  'bus_hours_sat_end_at',
  'bus_hours_sat_start_at',
  'bus_hours_sun_end_at',
  'bus_hours_sun_start_at',
  'bus_hours_thu_end_at',
  'bus_hours_thu_start_at',
  'bus_hours_tue_end_at',
  'bus_hours_tue_start_at',
  'bus_hours_wed_end_at',
  'bus_hours_wed_start_at',
  'ca_us_custom_broker_contact_name',
  'ca_us_custom_broker_email',
  'ca_us_custom_broker_name',
  'ca_us_custom_broker_notes',
  'ca_us_custom_broker_phone',
  'ca_us_custom_broker_phone_ext',
  'city',
  'country',
  'country',
  'credit_balance',
  'credit_limit',
  'currency_id',
  'default_billing_option',
  'default_dim_type',
  'default_order_notes',
  'dispatch_contact_email',
  'dispatch_contact_name',
  'dispatch_contact_phone',
  'email',
  'external_id',
  'fax',
  'is_active',
  'latitude',
  'longitude',
  'management_contact_email',
  'management_contact_name',
  'management_contact_phone',
  'name',
  'other_contact_email',
  'other_contact_name',
  'other_contact_phone',
  'phone',
  'phone_ext',
  'postal',
  'sales_contact_email',
  'sales_contact_name',
  'sales_contact_phone',
  'short_code',
  'state',
  'suite',
  'us_ca_custom_broker_contact_name',
  'us_ca_custom_broker_email',
  'us_ca_custom_broker_name',
  'us_ca_custom_broker_notes',
  'us_ca_custom_broker_phone',
  'us_ca_custom_broker_phone_ext' ]
  
[ 'accessorials',
  'billing',
  'billing_option',
  'commodities',
  'custom_broker',
  'customer',
  'declared_value',
  'declared_value_currency',
  'default_measurement_unit_id',
  'default_weight_unit_id',
  'delivery_appt_end_at',
  'delivery_appt_start_at',
  'delivery_end_at',
  'delivery_start_at',
  'destination',
  'dim_type',
  'external_id',
  'id',
  'notes',
  'origin',
  'pickup_appt_end_at',
  'pickup_appt_start_at',
  'pickup_end_at',
  'pickup_start_at',
  'po_num',
  'public_id',
  'ref_num',
  'sequence_id',
  'status',
  'tender_id',
  'tender_num' ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment