import { RpcMethodV3 } from './commonTypes'; import { Common_FailedPreconditions as pushwoosh_rpc_errors_v3_Common_FailedPreconditions } from './pushwoosh_rpc_errors_v3'; import { FilterExpression as pushwoosh_objects_filters_v1_FilterExpression } from './pushwoosh_objects_filters_v1'; export type SegmentsService_Create_FieldViolations = { reason: 'FV_UNSPECIFIED'; field: string; description: string; } | { reason: 'NAME_EMPTY'; field: string; description: string; } | { reason: 'NAME_TOO_LONG'; field: string; description: string; args: { max_length: string; }; } | { reason: 'NAME_ALREADY_EXISTS'; field: string; description: string; args: { name: string; }; } | { reason: 'EXPIRE_AT_IN_PAST'; field: string; description: string; } | { reason: 'CONDITIONS_REQUIRED'; field: string; description: string; } | { reason: 'SEGLANG_PARSE_ERROR'; field: string; description: string; args: { parser_error: string; }; } | { reason: 'FILTER_EXPRESSION_PARSE_ERROR'; field: string; description: string; args: { parser_error: string; }; } | { reason: 'FILTER_EXPRESSION_ONE_APP'; field: string; description: string; } | { reason: 'FILTER_EXPRESSION_TOO_DEEP'; field: string; description: string; args: { max_depth: string; }; } | { reason: 'FILTER_EXPRESSION_HIGH_SPEED_TAGS_ONLY'; field: string; description: string; } | { reason: 'FILTER_EXPRESSION_HIGH_SPEED_NO_DAYS_AGO'; field: string; description: string; } | { reason: 'FILTER_EXPRESSION_INVALID_COUNTRY_TAG_VALUE'; field: string; description: string; args: { value: string; }; } | { reason: 'FILTER_EXPRESSION_INVALID_LANGUAGE_TAG_VALUE'; field: string; description: string; args: { value: string; }; } | { reason: 'FILTER_EXPRESSION_EXTERNAL_SEGMENT_NOT_ALLOWED'; field: string; description: string; }; export type SegmentsService_Delete_FailedPreconditions = { type: 'FP_DELETE_UNSPECIFIED'; description: string; } | { type: 'SEGMENT_NOT_FOUND'; description: string; }; export type SegmentsService_Create_FailedPreconditions = { type: 'FP_UNSPECIFIED'; description: string; } | { type: 'HIGH_SPEED_SEGMENTS_NOT_ALLOWED'; description: string; } | { type: 'HIGH_SPEED_SEGMENTS_LIMIT_REACHED'; description: string; }; export type SegmentsService_List = RpcMethodV3; export type SegmentsService_Get = RpcMethodV3; export type SegmentsService_Create = RpcMethodV3; export type SegmentsService_Update = RpcMethodV3; export type SegmentsService_Delete = RpcMethodV3; export interface SegmentsService { /** Lists the segments (saved audience filters) belonging to an application. Use to browse an app's segments or find a segment code before fetching, updating or deleting one. */ List: SegmentsService_List; /** Returns a single segment by its segment code, including name and conditions in both seglang and filter-expression form. Use after list_segments to inspect one segment's definition. */ Get: SegmentsService_Get; /** Creates a segment from seglang or a filter expression for an application; the server generates and returns the segment code. Use to save a new audience filter; optionally high-speed for faster sending. */ Create: SegmentsService_Create; /** Updates an existing segment's name and/or conditions by segment code, replacing them with the supplied values. Use to rename or redefine a saved segment; for high-speed segments re-preparation takes time. */ Update: SegmentsService_Update; /** Deletes a segment by segment code and detaches it from in-app messages (moved to draft) and journey split/entry points. Irreversible; use only to permanently remove a segment. */ Delete: SegmentsService_Delete; } export type SegmentsService_Errors = { List: { failedPreconditions: pushwoosh_rpc_errors_v3_Common_FailedPreconditions; }; Get: { failedPreconditions: pushwoosh_rpc_errors_v3_Common_FailedPreconditions; }; Create: { fieldViolations: SegmentsService_Create_FieldViolations[]; failedPreconditions: SegmentsService_Create_FailedPreconditions | pushwoosh_rpc_errors_v3_Common_FailedPreconditions; }; Update: { failedPreconditions: pushwoosh_rpc_errors_v3_Common_FailedPreconditions; }; Delete: { failedPreconditions: SegmentsService_Delete_FailedPreconditions | pushwoosh_rpc_errors_v3_Common_FailedPreconditions; }; }; /** * DeviceLoadPolicy defines which devices will be loaded into segment during segmentation process. * FILTER - only devices matching the filter. This is the default. * ALL - all user's devices. */ export type DeviceLoadPolicy = 'FILTER' | 'ALL'; export type ListRequest = { /** Application code (format XXXXX-XXXXX) whose segments to list. */ application?: string; }; export type ListResponse = {}; export type GetRequest = { /** Segment code of the segment to fetch. */ segment?: string; }; /** Get segment response. Segment conditions are returned in both seglang and filter expression formats. */ export type GetResponse = { /** Owning application code. */ application: string; /** Segment code. */ code: string; /** Segment name. */ name: string; /** Segment conditions in seglang format. */ seglang: string; /** Segment conditions in filter expression format. */ filterExpression: pushwoosh_objects_filters_v1_FilterExpression; /** Device load policy. See DeviceLoadPolicy description for details. */ deviceLoadPolicy: DeviceLoadPolicy; /** Whether segment is high-speed. See CreateRequest for details. */ highSpeed: boolean; /** Whether high-speed segment is ready to use. See CreateRequest for details. */ highSpeedReady: boolean; highSpeedPreparedAt: Date; createdAt: Date; expireAt: Date; }; export type CreateRequest_conditions_seglang = { type: 'seglang'; data: string; }; export type CreateRequest_conditions_filterExpression = { type: 'filterExpression'; data: pushwoosh_objects_filters_v1_FilterExpression; }; export type CreateRequest_conditions = CreateRequest_conditions_seglang | CreateRequest_conditions_filterExpression; export type CreateRequest = { /** Application code to which segment belongs to. */ application?: string; /** * Segment name. Must be unique within account. * todo: make uniqueness per application, not account when all filters are migrated to applications. */ name?: string; /** See DeviceLoadPolicy description for details. If not set, it defaults to FILTER. */ deviceLoadPolicy?: DeviceLoadPolicy; /** * Whether segment will use high-speed infrastructure. High-speed segment will not return real-time data, but * they allow to omit segmentation process during sending and thus significantly increase sending speed. * High-speed segments are updated in background periodically. Typically every 15 minutes. * If high-speed segment is not updated in 3 hours, it becomes invalid until next successful update. * After creation high-speed segment will be unusable until the initial segmentation process is completed, * so it's recommended to create high-speed segments in advance before they are actually needed. * You can check whether the segment is ready by calling GetSegment and checking high_speed_ready flag. * Once segment is created with high-speed option, it cannot be changed. */ highSpeed?: boolean; /** * Segment expiration date. * If set, segment will be automatically deleted after given date. * Deletion process is performed in background and may take up to 1 hour after expiration date. * Expiration time is in UTC timezone and cannot be changed after creation. */ expireAt?: Date; conditions: CreateRequest_conditions; }; export type CreateResponse = { /** Owning application code. */ application: string; /** Segment code. */ code: string; /** Segment name. */ name: string; /** Segment conditions in seglang format. */ seglang: string; /** Segment conditions in filter expression format. */ filterExpression: pushwoosh_objects_filters_v1_FilterExpression; /** Device load policy. See DeviceLoadPolicy description for details. */ deviceLoadPolicy: DeviceLoadPolicy; /** Whether segment is high-speed. See CreateRequest for details. */ highSpeed: boolean; /** Whether high-speed segment is ready to use. See CreateRequest for details. */ highSpeedReady: boolean; /** Last time when high-speed segment was successfully updated and is ready to use. */ highSpeedPreparedAt: Date; /** Segment creation time. */ createdAt: Date; /** Segment expiration time. */ expireAt: Date; }; export type UpdateRequest_conditions_seglang = { type: 'seglang'; data: string; }; export type UpdateRequest_conditions_filterExpression = { type: 'filterExpression'; data: pushwoosh_objects_filters_v1_FilterExpression; }; export type UpdateRequest_conditions = UpdateRequest_conditions_seglang | UpdateRequest_conditions_filterExpression; export type UpdateRequest = { /** Segment code. */ segment?: string; /** New segment name. If set, it must not be empty string and must be unique within account. */ name?: string; conditions: UpdateRequest_conditions; }; export type UpdateResponse = {}; export type DeleteRequest = { /** Application code (format XXXXX-XXXXX) that owns the segment. */ application?: string; /** Segment code of the segment to delete. */ segment?: string; }; export type DeleteResponse = {};