"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const common_fields_1 = require("../common_fields");
const action = {
    title: 'Send Customer',
    description: 'Send a Customer (company) to ChartMogul CRM',
    defaultSubscription: 'type = "group"',
    fields: {
        type: { ...common_fields_1.event_type, default: 'Send Customer' },
        message_id: common_fields_1.message_id,
        timestamp: common_fields_1.timestamp,
        sent_at: common_fields_1.sent_at,
        user_id: { ...common_fields_1.user_id, required: true },
        group_id: {
            label: 'Group Id',
            description: 'Segment Group Id',
            type: 'string',
            required: true,
            default: { '@path': '$.groupId' }
        },
        name: {
            label: 'Name',
            description: "The company's name",
            type: 'string',
            default: { '@path': '$.traits.name' }
        },
        description: {
            label: 'Description',
            description: "The company's name",
            type: 'string',
            default: { '@path': '$.traits.description' }
        },
        email: {
            label: 'Email',
            description: "The company's email",
            type: 'string',
            format: 'email',
            default: { '@path': '$.traits.email' }
        },
        website: {
            label: 'Website',
            description: "The company's website URL",
            type: 'string',
            format: 'uri-reference',
            default: { '@path': '$.traits.website' }
        },
        created_at: {
            label: 'Created at',
            description: 'Date the group’s account was first created',
            type: 'datetime',
            default: { '@path': '$.traits.createdAt' }
        },
        address: {
            label: 'Address',
            type: 'object',
            description: 'The company’s address details',
            defaultObjectUI: 'keyvalue',
            properties: {
                street: {
                    label: 'Street',
                    type: 'string',
                    description: 'The company’s street address'
                },
                city: {
                    label: 'City',
                    type: 'string',
                    description: 'The company’s city'
                },
                state: {
                    label: 'State',
                    type: 'string',
                    description: 'The company’s state or region'
                },
                postal_code: {
                    label: 'Postal code',
                    type: 'string',
                    description: 'The company’s zip or postal code'
                },
                country: {
                    label: 'Country',
                    type: 'string',
                    description: 'The company’s country'
                }
            },
            default: {
                street: { '@path': '$.traits.address.street' },
                city: { '@path': '$.traits.address.city' },
                state: { '@path': '$.traits.address.state' },
                postal_code: { '@path': '$.traits.address.postalCode' },
                country: { '@path': '$.traits.address.country' }
            }
        }
    },
    perform: (request, data) => {
        return request(data.settings.chartmogul_webhook_url, {
            method: 'post',
            json: data.payload
        });
    }
};
exports.default = action;
//# sourceMappingURL=index.js.map