├── .github ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md └── SUPPORT.md ├── .gitignore ├── .gitmodules ├── CHANGELOG ├── COPYING ├── README.md ├── VERSION.txt ├── pom.xml └── src ├── main ├── java │ └── com │ │ └── urbanairship │ │ └── api │ │ ├── attributelists │ │ ├── AttributeListsCreateRequest.java │ │ ├── AttributeListsErrorsRequest.java │ │ ├── AttributeListsListingRequest.java │ │ ├── AttributeListsUploadRequest.java │ │ ├── model │ │ │ ├── AttributeListsListingResponse.java │ │ │ └── AttributeListsView.java │ │ └── parse │ │ │ ├── AttributeListsListingResponseDeserializer.java │ │ │ ├── AttributeListsObjectMapper.java │ │ │ ├── AttributeListsResponseReader.java │ │ │ ├── AttributeListsViewDeserializer.java │ │ │ └── AttributeListsViewReader.java │ │ ├── channel │ │ ├── ChannelAttributesRequest.java │ │ ├── ChannelRequest.java │ │ ├── ChannelTagRequest.java │ │ ├── ChannelUninstallRequest.java │ │ ├── Constants.java │ │ ├── OpenChannelRequest.java │ │ ├── OpenChannelTagRequest.java │ │ ├── OpenChannelUninstallRequest.java │ │ ├── SmsRegistrationRequest.java │ │ ├── SubscriptionListRequest.java │ │ ├── model │ │ │ ├── ChannelAttributesResponse.java │ │ │ ├── ChannelAudience.java │ │ │ ├── ChannelAudienceType.java │ │ │ ├── ChannelModelObject.java │ │ │ ├── ChannelResponse.java │ │ │ ├── ChannelType.java │ │ │ ├── ChannelUninstallDevice.java │ │ │ ├── ChannelUninstallDeviceType.java │ │ │ ├── ChannelUninstallPayload.java │ │ │ ├── ChannelUninstallResponse.java │ │ │ ├── ChannelView.java │ │ │ ├── OpenChannelResponse.java │ │ │ ├── SmsRegistrationResponse.java │ │ │ ├── attributes │ │ │ │ ├── Attribute.java │ │ │ │ ├── AttributeAction.java │ │ │ │ ├── ChannelAttributesPayload.java │ │ │ │ └── audience │ │ │ │ │ ├── AttributeAudience.java │ │ │ │ │ └── AttributeAudienceType.java │ │ │ ├── email │ │ │ │ ├── EmailChannelResponse.java │ │ │ │ ├── EmailTagRequest.java │ │ │ │ ├── OptInLevel.java │ │ │ │ ├── OptInMode.java │ │ │ │ ├── RegisterEmailChannel.java │ │ │ │ ├── RegisterEmailChannelRequest.java │ │ │ │ ├── ReplaceEmailChannelRequest.java │ │ │ │ ├── SuppressEmailChannelRequest.java │ │ │ │ ├── UninstallEmailChannel.java │ │ │ │ ├── UninstallEmailChannelRequest.java │ │ │ │ ├── UpdateEmailChannel.java │ │ │ │ └── UpdateEmailChannelRequest.java │ │ │ ├── ios │ │ │ │ ├── IosSettings.java │ │ │ │ └── QuietTime.java │ │ │ ├── open │ │ │ │ ├── Channel.java │ │ │ │ ├── OpenChannel.java │ │ │ │ └── OpenChannelPayload.java │ │ │ ├── sms │ │ │ │ ├── UpdateSmsChannel.java │ │ │ │ └── UpdateSmsChannelRequest.java │ │ │ ├── subscriptionlist │ │ │ │ ├── SubscriptionList.java │ │ │ │ ├── SubscriptionListAction.java │ │ │ │ ├── SubscriptionListPayload.java │ │ │ │ └── SubscriptionListResponse.java │ │ │ └── web │ │ │ │ ├── Subscription.java │ │ │ │ └── WebSettings.java │ │ └── parse │ │ │ ├── ChannelAudienceSerializer.java │ │ │ ├── ChannelObjectMapper.java │ │ │ ├── ChannelUninstallDeviceSerializer.java │ │ │ ├── ChannelUninstallResponseDeserializer.java │ │ │ ├── ChannelUninstallResponseReader.java │ │ │ ├── ChannelViewDeserializer.java │ │ │ ├── ChannelViewReader.java │ │ │ ├── ChannelsResponseDeserializer.java │ │ │ ├── ChannelsResponseReader.java │ │ │ ├── OpenChannelResponseDeserializer.java │ │ │ ├── OpenChannelResponseReader.java │ │ │ ├── SmsRegistrationResponseDeserializer.java │ │ │ ├── SmsRegistrationResponseReader.java │ │ │ ├── attributes │ │ │ ├── AttributeSerializer.java │ │ │ ├── ChannelAttributesPayloadSerializer.java │ │ │ ├── ChannelAttributesResponseDeserializer.java │ │ │ ├── ChannelAttributesResponseReader.java │ │ │ └── audience │ │ │ │ └── AttributeAudienceSerializer.java │ │ │ ├── email │ │ │ ├── RegisterEmailChannelResponseDeserializer.java │ │ │ ├── RegisterEmailChannelResponseReader.java │ │ │ ├── RegisterEmailChannelSerializer.java │ │ │ ├── UninstallEmailChannelSerializer.java │ │ │ ├── UpdateEmailChannelResponseDeserializer.java │ │ │ ├── UpdateEmailChannelResponseReader.java │ │ │ └── UpdateEmailChannelSerializer.java │ │ │ ├── ios │ │ │ ├── IosSettingsDeserializer.java │ │ │ ├── IosSettingsReader.java │ │ │ ├── QuietTimeDeserializer.java │ │ │ └── QuietTimeReader.java │ │ │ ├── open │ │ │ ├── ChannelSerializer.java │ │ │ ├── OpenChannelDeserializer.java │ │ │ ├── OpenChannelReader.java │ │ │ └── OpenChannelSerializer.java │ │ │ ├── sms │ │ │ └── UpdateSmsChannelSerializer.java │ │ │ ├── subscriptionlist │ │ │ ├── SubscriptionListPayloadSerializer.java │ │ │ ├── SubscriptionListResponseDeserializer.java │ │ │ └── SubscriptionListResponseReader.java │ │ │ └── web │ │ │ ├── SubscriptionDeserializer.java │ │ │ ├── SubscriptionReader.java │ │ │ ├── WebSettingsDeserializer.java │ │ │ └── WebSettingsReader.java │ │ ├── client │ │ ├── AsyncRequestClient.java │ │ ├── ClientException.java │ │ ├── OAuthCredentials.java │ │ ├── OAuthTokenFetcher.java │ │ ├── Request.java │ │ ├── RequestClient.java │ │ ├── RequestError.java │ │ ├── RequestErrorDetails.java │ │ ├── RequestRetryFilter.java │ │ ├── RequestUtils.java │ │ ├── Response.java │ │ ├── ResponseAsyncHandler.java │ │ ├── ResponseCallback.java │ │ ├── ResponseParser.java │ │ ├── ServerException.java │ │ ├── UrbanAirshipClient.java │ │ └── parse │ │ │ ├── OAuthTokenResponse.java │ │ │ ├── RequestErrorDeserializer.java │ │ │ ├── RequestErrorDetailsDeserializer.java │ │ │ ├── RequestErrorDetailsReader.java │ │ │ ├── RequestErrorObjectMapper.java │ │ │ ├── RequestErrorReader.java │ │ │ ├── StreamLocationDeserializer.java │ │ │ └── StreamLocationReader.java │ │ ├── common │ │ ├── CSVUtils.java │ │ ├── model │ │ │ ├── APIModelObject.java │ │ │ ├── ErrorDetails.java │ │ │ └── GenericResponse.java │ │ └── parse │ │ │ ├── APIParsingException.java │ │ │ ├── BooleanFieldDeserializer.java │ │ │ ├── CommonObjectMapper.java │ │ │ ├── DateFormats.java │ │ │ ├── DateTimeDeserializer.java │ │ │ ├── DateTimeSerializer.java │ │ │ ├── FieldParser.java │ │ │ ├── FieldParserRegistry.java │ │ │ ├── IntFieldDeserializer.java │ │ │ ├── JsonObjectReader.java │ │ │ ├── ListOfStringsDeserializer.java │ │ │ ├── MapFieldParserRegistry.java │ │ │ ├── MapOfStringsDeserializer.java │ │ │ ├── StandardObjectDeserializer.java │ │ │ └── StringFieldDeserializer.java │ │ ├── createandsend │ │ ├── CreateAndSendRequest.java │ │ ├── CreateAndSendScheduleRequest.java │ │ ├── model │ │ │ ├── audience │ │ │ │ ├── CreateAndSendAudience.java │ │ │ │ ├── email │ │ │ │ │ ├── EmailChannel.java │ │ │ │ │ ├── EmailChannels.java │ │ │ │ │ └── EmailOptInType.java │ │ │ │ └── sms │ │ │ │ │ ├── SmsChannel.java │ │ │ │ │ └── SmsChannels.java │ │ │ └── notification │ │ │ │ ├── CreateAndSendPayload.java │ │ │ │ ├── CreateAndSendSchedulePayload.java │ │ │ │ ├── email │ │ │ │ ├── CreateAndSendEmailPayload.java │ │ │ │ ├── EmailFields.java │ │ │ │ ├── EmailTemplate.java │ │ │ │ └── VariableDetail.java │ │ │ │ └── sms │ │ │ │ ├── SmsFields.java │ │ │ │ ├── SmsPayload.java │ │ │ │ └── SmsTemplate.java │ │ └── parse │ │ │ ├── CreateAndSendEmailChannelSerializer.java │ │ │ ├── audience │ │ │ └── CreateAndSendAudienceSerializer.java │ │ │ └── notification │ │ │ ├── CreateAndSendPayloadSerializer.java │ │ │ ├── CreateAndSendSchedulePayloadSerializer.java │ │ │ ├── email │ │ │ ├── CreateAndSendEmailPayloadSerializer.java │ │ │ ├── EmailFieldsSerializer.java │ │ │ ├── EmailTemplateSerializer.java │ │ │ └── VariableDetailSerializer.java │ │ │ └── sms │ │ │ ├── SmsFieldsSerializer.java │ │ │ ├── SmsPayloadSerializer.java │ │ │ └── SmsTemplateSerializer.java │ │ ├── customevents │ │ ├── CustomEventRequest.java │ │ ├── model │ │ │ ├── CustomEventBody.java │ │ │ ├── CustomEventChannelType.java │ │ │ ├── CustomEventPayload.java │ │ │ ├── CustomEventPropertyValue.java │ │ │ ├── CustomEventResponse.java │ │ │ └── CustomEventUser.java │ │ └── parse │ │ │ ├── CustomEventBodySerializer.java │ │ │ ├── CustomEventPropertyValueSerializer.java │ │ │ ├── CustomEventResponseDeserializer.java │ │ │ ├── CustomEventResponseReader.java │ │ │ ├── CustomEventSerializer.java │ │ │ └── CustomEventUserSerializer.java │ │ ├── email │ │ ├── EmailAttachmentRequest.java │ │ └── model │ │ │ └── EmailAttachmentResponse.java │ │ ├── experiments │ │ ├── ExperimentDeleteRequest.java │ │ ├── ExperimentRequest.java │ │ ├── model │ │ │ ├── Experiment.java │ │ │ ├── ExperimentModelObject.java │ │ │ ├── ExperimentResponse.java │ │ │ ├── Variant.java │ │ │ └── VariantPushPayload.java │ │ └── parse │ │ │ ├── ExperimentDeserializer.java │ │ │ ├── ExperimentObjectMapper.java │ │ │ ├── ExperimentReader.java │ │ │ ├── ExperimentResponseDeserializer.java │ │ │ ├── ExperimentResponseReader.java │ │ │ ├── ExperimentSerializer.java │ │ │ ├── VariantDeserializer.java │ │ │ ├── VariantPushPayloadDeserializer.java │ │ │ ├── VariantPushPayloadReader.java │ │ │ ├── VariantPushPayloadSerializer.java │ │ │ ├── VariantReader.java │ │ │ └── VariantSerializer.java │ │ ├── inbox │ │ ├── InboxBatchDeleteRequest.java │ │ ├── InboxDeleteRequest.java │ │ └── model │ │ │ ├── InboxBatchDeleteResponse.java │ │ │ └── MessageIdError.java │ │ ├── nameduser │ │ ├── NamedUserAttributeRequest.java │ │ ├── NamedUserListingRequest.java │ │ ├── NamedUserRequest.java │ │ ├── NamedUserScopedRequest.java │ │ ├── NamedUserTagRequest.java │ │ ├── NamedUserUninstallRequest.java │ │ ├── NamedUserUpdateRequest.java │ │ ├── model │ │ │ ├── NamedUserAttributePayload.java │ │ │ ├── NamedUserAttributeResponse.java │ │ │ ├── NamedUserListingResponse.java │ │ │ ├── NamedUserModelObject.java │ │ │ ├── NamedUserScope.java │ │ │ ├── NamedUserScopeType.java │ │ │ ├── NamedUserScopedPayload.java │ │ │ ├── NamedUserUpdateChannel.java │ │ │ ├── NamedUserUpdateChannelAction.java │ │ │ ├── NamedUserUpdateDeviceType.java │ │ │ ├── NamedUserUpdatePayload.java │ │ │ ├── NamedUserUpdateResponse.java │ │ │ └── NamedUserView.java │ │ └── parse │ │ │ ├── NamedUserAttributePayloadSerializer.java │ │ │ ├── NamedUserAttributeResponseDeserializer.java │ │ │ ├── NamedUserAttributeResponseReader.java │ │ │ ├── NamedUserListingResponseReader.java │ │ │ ├── NamedUserObjectMapper.java │ │ │ ├── NamedUserScopeSerializer.java │ │ │ ├── NamedUserScopedPayloadSerializer.java │ │ │ ├── NamedUserUpdateChannelSerializer.java │ │ │ ├── NamedUserUpdatePayloadSerializer.java │ │ │ ├── NamedUserUpdateResponseDeserializer.java │ │ │ ├── NamedUserUpdateResponseReader.java │ │ │ ├── NamedUserViewDeserializer.java │ │ │ ├── NamedUserViewReader.java │ │ │ └── NamedUserlListingResponseDeserializer.java │ │ ├── oauth │ │ └── PublicKeyVerificationRequest.java │ │ ├── push │ │ ├── PushRequest.java │ │ ├── model │ │ │ ├── Campaigns.java │ │ │ ├── DeviceType.java │ │ │ ├── DeviceTypeData.java │ │ │ ├── Display.java │ │ │ ├── InApp.java │ │ │ ├── Orchestration.java │ │ │ ├── OrchestrationType.java │ │ │ ├── Position.java │ │ │ ├── PushExpiry.java │ │ │ ├── PushModelObject.java │ │ │ ├── PushOptions.java │ │ │ ├── PushPayload.java │ │ │ ├── PushResponse.java │ │ │ ├── audience │ │ │ │ ├── BasicCompoundSelector.java │ │ │ │ ├── BasicSelector.java │ │ │ │ ├── BasicValueSelector.java │ │ │ │ ├── CompoundSelector.java │ │ │ │ ├── Selector.java │ │ │ │ ├── SelectorCategory.java │ │ │ │ ├── SelectorType.java │ │ │ │ ├── SelectorVisitor.java │ │ │ │ ├── Selectors.java │ │ │ │ ├── ValueSelector.java │ │ │ │ ├── createandsend │ │ │ │ │ └── OpenChannel.java │ │ │ │ ├── location │ │ │ │ │ ├── AbsoluteDateRange.java │ │ │ │ │ ├── DateRange.java │ │ │ │ │ ├── DateRangeUnit.java │ │ │ │ │ ├── LocationAlias.java │ │ │ │ │ ├── LocationIdentifier.java │ │ │ │ │ ├── LocationSelector.java │ │ │ │ │ ├── PresenceTimeframe.java │ │ │ │ │ ├── RecentDateRange.java │ │ │ │ │ └── SegmentDefinition.java │ │ │ │ └── sms │ │ │ │ │ └── SmsSelector.java │ │ │ ├── localization │ │ │ │ └── Localization.java │ │ │ └── notification │ │ │ │ ├── DevicePayloadOverride.java │ │ │ │ ├── Interactive.java │ │ │ │ ├── Notification.java │ │ │ │ ├── NotificationPayloadOverrideKey.java │ │ │ │ ├── Notifications.java │ │ │ │ ├── actions │ │ │ │ ├── Action.java │ │ │ │ ├── ActionNameRegistry.java │ │ │ │ ├── ActionType.java │ │ │ │ ├── Actions.java │ │ │ │ ├── AddTagAction.java │ │ │ │ ├── AppDefinedAction.java │ │ │ │ ├── DeepLinkAction.java │ │ │ │ ├── LandingPageContent.java │ │ │ │ ├── OpenExternalURLAction.java │ │ │ │ ├── OpenLandingPageWithContentAction.java │ │ │ │ ├── RemoveTagAction.java │ │ │ │ ├── ShareAction.java │ │ │ │ └── TagActionData.java │ │ │ │ ├── adm │ │ │ │ ├── ADMDevicePayload.java │ │ │ │ ├── ADMFields.java │ │ │ │ └── ADMTemplate.java │ │ │ │ ├── android │ │ │ │ ├── AndroidDevicePayload.java │ │ │ │ ├── AndroidFields.java │ │ │ │ ├── AndroidLiveUpdate.java │ │ │ │ ├── AndroidLiveUpdateEvent.java │ │ │ │ ├── AndroidTemplate.java │ │ │ │ ├── BigPictureStyle.java │ │ │ │ ├── BigTextStyle.java │ │ │ │ ├── Category.java │ │ │ │ ├── InboxStyle.java │ │ │ │ ├── PublicNotification.java │ │ │ │ ├── Style.java │ │ │ │ └── Wearable.java │ │ │ │ ├── email │ │ │ │ ├── Attachment.java │ │ │ │ ├── EmailPayload.java │ │ │ │ └── MessageType.java │ │ │ │ ├── ios │ │ │ │ ├── Crop.java │ │ │ │ ├── IOSAlertData.java │ │ │ │ ├── IOSBadgeData.java │ │ │ │ ├── IOSDevicePayload.java │ │ │ │ ├── IOSFields.java │ │ │ │ ├── IOSInterruptionLevel.java │ │ │ │ ├── IOSLiveActivity.java │ │ │ │ ├── IOSLiveActivityAlert.java │ │ │ │ ├── IOSLiveActivityEvent.java │ │ │ │ ├── IOSMediaContent.java │ │ │ │ ├── IOSMediaOptions.java │ │ │ │ ├── IOSSoundData.java │ │ │ │ ├── IOSTemplate.java │ │ │ │ └── MediaAttachment.java │ │ │ │ ├── open │ │ │ │ └── OpenPayload.java │ │ │ │ ├── richpush │ │ │ │ ├── RichPushFields.java │ │ │ │ ├── RichPushIcon.java │ │ │ │ ├── RichPushMessage.java │ │ │ │ └── RichPushTemplate.java │ │ │ │ ├── sms │ │ │ │ └── SmsPayload.java │ │ │ │ ├── web │ │ │ │ ├── Button.java │ │ │ │ ├── WebDevicePayload.java │ │ │ │ ├── WebFields.java │ │ │ │ ├── WebIcon.java │ │ │ │ ├── WebImage.java │ │ │ │ └── WebTemplate.java │ │ │ │ └── wns │ │ │ │ ├── WNSAudioData.java │ │ │ │ ├── WNSBadgeData.java │ │ │ │ ├── WNSBinding.java │ │ │ │ ├── WNSDevicePayload.java │ │ │ │ ├── WNSPush.java │ │ │ │ ├── WNSTileData.java │ │ │ │ └── WNSToastData.java │ │ └── parse │ │ │ ├── CampaignsSerializer.java │ │ │ ├── DeviceTypeDataSerializer.java │ │ │ ├── DeviceTypeSerializer.java │ │ │ ├── DisplayDeserializer.java │ │ │ ├── DisplayReader.java │ │ │ ├── DisplaySerializer.java │ │ │ ├── InAppDeserializer.java │ │ │ ├── InAppReader.java │ │ │ ├── InAppSerializer.java │ │ │ ├── OrchestrationDeserializer.java │ │ │ ├── OrchestrationReader.java │ │ │ ├── OrchestrationSerializer.java │ │ │ ├── PlatformDataDeserializer.java │ │ │ ├── PlatformDeserializer.java │ │ │ ├── PushExpiryDeserializer.java │ │ │ ├── PushExpirySerializer.java │ │ │ ├── PushObjectMapper.java │ │ │ ├── PushOptionsDeserializer.java │ │ │ ├── PushOptionsReader.java │ │ │ ├── PushOptionsSerializer.java │ │ │ ├── PushPayloadDeserializer.java │ │ │ ├── PushPayloadReader.java │ │ │ ├── PushPayloadSerializer.java │ │ │ ├── PushResponseDeserializer.java │ │ │ ├── PushResponseReader.java │ │ │ ├── audience │ │ │ ├── SelectorDeserializer.java │ │ │ ├── SelectorReader.java │ │ │ ├── SelectorSerializer.java │ │ │ ├── Validation.java │ │ │ ├── location │ │ │ │ ├── AbsoluteDateRangeDeserializer.java │ │ │ │ ├── AbsoluteDateRangeReader.java │ │ │ │ ├── AbsoluteDateRangeSerializer.java │ │ │ │ ├── DateRangeDeserializer.java │ │ │ │ ├── DateRangeReader.java │ │ │ │ ├── LocationSelectorDeserializer.java │ │ │ │ ├── LocationSelectorReader.java │ │ │ │ ├── LocationSelectorSerializer.java │ │ │ │ ├── RecentDateRangeDeserializer.java │ │ │ │ ├── RecentDateRangeReader.java │ │ │ │ ├── RecentDateRangeSerializer.java │ │ │ │ ├── SegmentDefinitionDeserializer.java │ │ │ │ └── SegmentDefinitionReader.java │ │ │ └── sms │ │ │ │ └── SmsSelectorSerializer.java │ │ │ ├── localization │ │ │ └── LocalizationSerializer.java │ │ │ └── notification │ │ │ ├── InteractiveDeserializer.java │ │ │ ├── InteractiveReader.java │ │ │ ├── InteractiveSerializer.java │ │ │ ├── NotificationDeserializer.java │ │ │ ├── NotificationReader.java │ │ │ ├── NotificationSerializer.java │ │ │ ├── actions │ │ │ ├── ActionsDeserializer.java │ │ │ ├── ActionsReader.java │ │ │ ├── ActionsSerializer.java │ │ │ ├── AddTagActionSerializer.java │ │ │ ├── AppDefinedSerializer.java │ │ │ ├── DeepLinkSerializer.java │ │ │ ├── ExternalURLSerializer.java │ │ │ ├── LandingPageWithContentSerializer.java │ │ │ ├── RemoveTagActionSerializer.java │ │ │ ├── ShareActionDeserializer.java │ │ │ ├── ShareActionSerializer.java │ │ │ ├── TagActionDataDeserializer.java │ │ │ └── TagActionDataSerializer.java │ │ │ ├── adm │ │ │ ├── ADMDevicePayloadDeserializer.java │ │ │ ├── ADMDevicePayloadReader.java │ │ │ ├── ADMDevicePayloadSerializer.java │ │ │ ├── ADMFieldsDeserializer.java │ │ │ └── ADMTemplateDeserializer.java │ │ │ ├── android │ │ │ ├── AndroidDevicePayloadDeserializer.java │ │ │ ├── AndroidDevicePayloadReader.java │ │ │ ├── AndroidDevicePayloadSerializer.java │ │ │ ├── AndroidFieldsDeserializer.java │ │ │ ├── AndroidLiveUpdateSerializer.java │ │ │ ├── AndroidTemplateDeserializer.java │ │ │ ├── BigPictureStyleDeserializer.java │ │ │ ├── BigPictureStyleReader.java │ │ │ ├── BigPictureStyleSerializer.java │ │ │ ├── BigTextStyleDeserializer.java │ │ │ ├── BigTextStyleReader.java │ │ │ ├── BigTextStyleSerializer.java │ │ │ ├── CategoryDeserializer.java │ │ │ ├── InboxStyleDeserializer.java │ │ │ ├── InboxStyleReader.java │ │ │ ├── InboxStyleSerializer.java │ │ │ ├── PublicNotificationDeserializer.java │ │ │ ├── PublicNotificationReader.java │ │ │ ├── PublicNotificationSerializer.java │ │ │ ├── WearableDeserializer.java │ │ │ ├── WearableReader.java │ │ │ └── WearableSerializer.java │ │ │ ├── email │ │ │ ├── EmailPayloadDeserializer.java │ │ │ ├── EmailPayloadReader.java │ │ │ └── EmailPayloadSerializer.java │ │ │ ├── ios │ │ │ ├── CropDeserializer.java │ │ │ ├── CropPayloadReader.java │ │ │ ├── CropSerializer.java │ │ │ ├── IOSAlertDataDeserializer.java │ │ │ ├── IOSAlertDataReader.java │ │ │ ├── IOSAlertDataSerializer.java │ │ │ ├── IOSBadgeDataDeserializer.java │ │ │ ├── IOSBadgeDataSerializer.java │ │ │ ├── IOSDevicePayloadDeserializer.java │ │ │ ├── IOSDevicePayloadReader.java │ │ │ ├── IOSDevicePayloadSerializer.java │ │ │ ├── IOSFieldsDeserializer.java │ │ │ ├── IOSInterruptionLevelDeserializer.java │ │ │ ├── IOSLiveActivityAlertSerializer.java │ │ │ ├── IOSLiveActivitySerializer.java │ │ │ ├── IOSMediaContentDeserializer.java │ │ │ ├── IOSMediaContentReader.java │ │ │ ├── IOSMediaContentSerializer.java │ │ │ ├── IOSMediaOptionsDeserializer.java │ │ │ ├── IOSMediaOptionsPayloadReader.java │ │ │ ├── IOSMediaOptionsSerializer.java │ │ │ ├── IOSSoundDataDeserializer.java │ │ │ ├── IOSSoundDataReader.java │ │ │ ├── IOSSoundDataSerializer.java │ │ │ ├── IOSTemplateDeserializer.java │ │ │ ├── MediaAttachmentDeserializer.java │ │ │ ├── MediaAttachmentReader.java │ │ │ └── MediaAttachmentSerializer.java │ │ │ ├── open │ │ │ └── OpenPayloadSerializer.java │ │ │ ├── richpush │ │ │ ├── RichPushIconDeserializer.java │ │ │ ├── RichPushIconReader.java │ │ │ ├── RichPushIconSerializer.java │ │ │ ├── RichPushMessageDeserializer.java │ │ │ ├── RichPushMessageReader.java │ │ │ └── RichPushMessageSerializer.java │ │ │ ├── sms │ │ │ ├── SmsPayloadDeserializer.java │ │ │ ├── SmsPayloadReader.java │ │ │ └── SmsPayloadSerializer.java │ │ │ ├── web │ │ │ ├── ButtonDeserializer.java │ │ │ ├── ButtonReader.java │ │ │ ├── ButtonSerializer.java │ │ │ ├── WebDevicePayloadDeserializer.java │ │ │ ├── WebDevicePayloadReader.java │ │ │ ├── WebDevicePayloadSerializer.java │ │ │ ├── WebFieldsDeserializer.java │ │ │ ├── WebIconDeserializer.java │ │ │ ├── WebIconReader.java │ │ │ ├── WebIconSerializer.java │ │ │ ├── WebImageDeserializer.java │ │ │ ├── WebImageReader.java │ │ │ ├── WebImageSerializer.java │ │ │ └── WebTemplateDeserializer.java │ │ │ └── wns │ │ │ ├── WNSAudioDeserializer.java │ │ │ ├── WNSAudioReader.java │ │ │ ├── WNSAudioSerializer.java │ │ │ ├── WNSBadgeDeserializer.java │ │ │ ├── WNSBadgeReader.java │ │ │ ├── WNSBadgeSerializer.java │ │ │ ├── WNSBindingDeserializer.java │ │ │ ├── WNSBindingReader.java │ │ │ ├── WNSBindingSerializer.java │ │ │ ├── WNSCachePolicyDeserializer.java │ │ │ ├── WNSCachePolicySerializer.java │ │ │ ├── WNSDevicePayloadDeserializer.java │ │ │ ├── WNSDevicePayloadReader.java │ │ │ ├── WNSDevicePayloadSerializer.java │ │ │ ├── WNSDurationDeserializer.java │ │ │ ├── WNSDurationSerializer.java │ │ │ ├── WNSGlyphDeserializer.java │ │ │ ├── WNSGlyphSerializer.java │ │ │ ├── WNSSoundDeserializer.java │ │ │ ├── WNSSoundSerializer.java │ │ │ ├── WNSTileDeserializer.java │ │ │ ├── WNSTileReader.java │ │ │ ├── WNSTileSerializer.java │ │ │ ├── WNSToastDeserializer.java │ │ │ ├── WNSToastReader.java │ │ │ └── WNSToastSerializer.java │ │ ├── reports │ │ ├── Base64ByteArray.java │ │ ├── CustomEventsDetailsListingRequest.java │ │ ├── DevicesReportRequest.java │ │ ├── ExperimentOverviewReportRequest.java │ │ ├── ExperimentVariantReportRequest.java │ │ ├── PlatformStatsRequest.java │ │ ├── PlatformStatsRequestType.java │ │ ├── PushInfoRequest.java │ │ ├── PushListingRequest.java │ │ ├── ResponseReportRequest.java │ │ ├── WebResponseReportRequest.java │ │ ├── model │ │ │ ├── CustomEventsDetailResponse.java │ │ │ ├── CustomEventsDetailsListingResponse.java │ │ │ ├── DeviceStats.java │ │ │ ├── DeviceTypeStats.java │ │ │ ├── DevicesReport.java │ │ │ ├── DevicesReportResponse.java │ │ │ ├── ExperimentControl.java │ │ │ ├── ExperimentOverviewReportResponse.java │ │ │ ├── ExperimentVariant.java │ │ │ ├── ExperimentVariantReportResponse.java │ │ │ ├── ExperimentVariantStats.java │ │ │ ├── PlatformStats.java │ │ │ ├── PlatformStatsResponse.java │ │ │ ├── PlatformType.java │ │ │ ├── Precision.java │ │ │ ├── PushInfoResponse.java │ │ │ ├── PushListingResponse.java │ │ │ ├── ResponseReport.java │ │ │ ├── ResponseReportResponse.java │ │ │ ├── WebCounts.java │ │ │ ├── WebCountsStats.java │ │ │ └── WebResponseReportResponse.java │ │ └── parse │ │ │ ├── DeviceStatsDeserializer.java │ │ │ ├── DeviceStatsReader.java │ │ │ ├── DeviceTypeStatsDeserializer.java │ │ │ ├── DeviceTypeStatsReader.java │ │ │ ├── DevicesReportDeserializer.java │ │ │ ├── DevicesReportReader.java │ │ │ ├── DevicesReportResponseDeserializer.java │ │ │ ├── DevicesReportResponseReader.java │ │ │ ├── PlatformStatsDeserializer.java │ │ │ ├── PlatformStatsReader.java │ │ │ ├── PlatformStatsResponseDeserializer.java │ │ │ ├── PlatformStatsResponseReader.java │ │ │ ├── PushInfoResponseDeserializer.java │ │ │ ├── PushInfoResponseReader.java │ │ │ ├── PushListingResponseDeserializer.java │ │ │ ├── PushListingResponseReader.java │ │ │ ├── ReportsObjectMapper.java │ │ │ ├── ResponseReportDeserializer.java │ │ │ ├── ResponseReportReader.java │ │ │ ├── ResponseReportResponseDeserializer.java │ │ │ └── ResponseReportResponseReader.java │ │ ├── schedule │ │ ├── ListSchedulesOrderType.java │ │ ├── ScheduleDeleteRequest.java │ │ ├── ScheduleListingRequest.java │ │ ├── ScheduleRequest.java │ │ ├── ScheduleStatusRequest.java │ │ ├── model │ │ │ ├── BestTime.java │ │ │ ├── ListAllSchedulesResponse.java │ │ │ ├── Schedule.java │ │ │ ├── ScheduleDetails.java │ │ │ ├── ScheduleModelObject.java │ │ │ ├── SchedulePayload.java │ │ │ ├── SchedulePayloadResponse.java │ │ │ ├── ScheduleResponse.java │ │ │ └── ScheduleValidator.java │ │ └── parse │ │ │ ├── BestTimeDeserializer.java │ │ │ ├── BestTimeReader.java │ │ │ ├── BestTimeSerializer.java │ │ │ ├── ListSchedulesResponseDeserializer.java │ │ │ ├── ListSchedulesResponseReader.java │ │ │ ├── ScheduleDeserializer.java │ │ │ ├── ScheduleDetailsSerializer.java │ │ │ ├── ScheduleObjectMapper.java │ │ │ ├── SchedulePayloadResponseDeserializer.java │ │ │ ├── SchedulePayloadResponseReader.java │ │ │ ├── ScheduleReader.java │ │ │ ├── ScheduleResponseDeserializer.java │ │ │ ├── ScheduleResponseReader.java │ │ │ ├── ScheduleSerializer.java │ │ │ ├── ScheduledPayloadSerializer.java │ │ │ └── TimeZones.java │ │ ├── segments │ │ ├── SegmentDeleteRequest.java │ │ ├── SegmentListingRequest.java │ │ ├── SegmentLookupRequest.java │ │ ├── SegmentRequest.java │ │ ├── model │ │ │ ├── SegmentListingResponse.java │ │ │ ├── SegmentListingView.java │ │ │ ├── SegmentRequestResponse.java │ │ │ └── SegmentView.java │ │ └── parse │ │ │ ├── SegmentListingResponseDeserializer.java │ │ │ ├── SegmentListingResponseReader.java │ │ │ ├── SegmentListingViewDeserializer.java │ │ │ ├── SegmentListingViewReader.java │ │ │ ├── SegmentObjectMapper.java │ │ │ ├── SegmentViewDeserializer.java │ │ │ ├── SegmentViewReader.java │ │ │ └── SegmentViewSerializer.java │ │ ├── sms │ │ ├── CustomSmsResponseRequest.java │ │ ├── KeywordInteractionRequest.java │ │ ├── model │ │ │ ├── CustomSmsResponseMmsPayload.java │ │ │ ├── CustomSmsResponseResponse.java │ │ │ ├── CustomSmsResponseSmsPayload.java │ │ │ ├── MmsSlides.java │ │ │ └── SmsModelObject.java │ │ └── parse │ │ │ ├── CustomSmsResponseMmsPayloadSerializer.java │ │ │ ├── CustomSmsResponseResponseDeserializer.java │ │ │ ├── CustomSmsResponseResponseReader.java │ │ │ ├── CustomSmsResponseSmsPayloadSerializer.java │ │ │ ├── MmsSlidesSerializer.java │ │ │ └── SmsObjectMapper.java │ │ ├── staticlists │ │ ├── LifecycleListType.java │ │ ├── StaticListDeleteRequest.java │ │ ├── StaticListDownloadRequest.java │ │ ├── StaticListListingRequest.java │ │ ├── StaticListLookupRequest.java │ │ ├── StaticListRequest.java │ │ ├── StaticListUploadRequest.java │ │ ├── model │ │ │ ├── StaticListListingResponse.java │ │ │ └── StaticListView.java │ │ └── parse │ │ │ ├── StaticListListingResponseDeserializer.java │ │ │ ├── StaticListListingResponseReader.java │ │ │ ├── StaticListViewDeserializer.java │ │ │ ├── StaticListViewReader.java │ │ │ └── StaticListsObjectMapper.java │ │ ├── subscriptionlists │ │ ├── NamedUserSubscriptionListsListingRequest.java │ │ ├── SubscriptionListListingRequest.java │ │ └── model │ │ │ ├── ContactSubscriptionListView.java │ │ │ ├── NamedUserSubscriptionListsListingResponse.java │ │ │ ├── SubscriptionListListingResponse.java │ │ │ └── SubscriptionListView.java │ │ ├── tags │ │ ├── TagListErrorsRequest.java │ │ ├── TagListListingRequest.java │ │ ├── TagListRequest.java │ │ ├── TagListUploadRequest.java │ │ └── model │ │ │ ├── TagListListingResponse.java │ │ │ └── TagListView.java │ │ └── templates │ │ ├── TemplateDeleteRequest.java │ │ ├── TemplateListingRequest.java │ │ ├── TemplatePushRequest.java │ │ ├── TemplateRequest.java │ │ ├── TemplateScheduledPushRequest.java │ │ ├── model │ │ ├── PartialPushPayload.java │ │ ├── TemplateListingResponse.java │ │ ├── TemplatePushPayload.java │ │ ├── TemplateResponse.java │ │ ├── TemplateScheduledPushPayload.java │ │ ├── TemplateSelector.java │ │ ├── TemplateVariable.java │ │ └── TemplateView.java │ │ └── parse │ │ ├── PartialPushPayloadDeserializer.java │ │ ├── PartialPushPayloadReader.java │ │ ├── PartialPushPayloadSerializer.java │ │ ├── TemplateListingResponseDeserializer.java │ │ ├── TemplateListingResponseReader.java │ │ ├── TemplatePushPayloadSerializer.java │ │ ├── TemplateResponseDeserializer.java │ │ ├── TemplateResponseReader.java │ │ ├── TemplateScheduledPushPayloadSerializer.java │ │ ├── TemplateSelectorSerializer.java │ │ ├── TemplateVariableDeserializer.java │ │ ├── TemplateVariableReader.java │ │ ├── TemplateVariableSerializer.java │ │ ├── TemplateViewDeserializer.java │ │ ├── TemplateViewReader.java │ │ ├── TemplateViewSerializer.java │ │ └── TemplatesObjectMapper.java └── resources │ └── client.properties └── test ├── data ├── test.csv ├── test2.csv └── test_tag_list.csv └── java └── com └── urbanairship └── api ├── attributelists ├── AttributeListsCreateRequestTest.java ├── AttributeListsErrorsRequestTest.java ├── AttributeListsListingRequestTest.java ├── AttributeListsUploadRequestTest.java ├── model │ ├── AttributeListsListingResponseTest.java │ └── AttributeListsViewTest.java └── parse │ ├── AttributeListsListingResponseDeserializerTest.java │ └── AttributeListsViewDeserializerTest.java ├── channel ├── ChannelRequestTest.java ├── ChannelResponseTest.java ├── ChannelTagRequestTest.java ├── ChannelUninstallRequestTest.java ├── OpenChannelRequestTest.java ├── OpenChannelTagRequestTest.java ├── OpenChannelUninstallRequestTest.java ├── SmsRegistrationRequestTest.java ├── SubscriptionListRequestTest.java ├── email │ ├── model │ │ ├── EmailTagRequestTest.java │ │ ├── RegisterEmailChannelRequestTest.java │ │ ├── ReplaceEmailChannelRequestTest.java │ │ ├── SuppressEmailChannelRequestTest.java │ │ ├── UninstallEmailChannelTest.java │ │ └── UpdateEmailChannelRequestTest.java │ └── parse │ │ ├── EmailRegisterChannelPayloadSerializerTest.java │ │ ├── EmailRegisterChannelResponseDeserializerTest.java │ │ └── EmailUpdateChannelPayloadSerializerTest.java ├── model │ └── attributes │ │ └── AttributeTest.java ├── open │ └── OpenChannelPayloadSerializerTest.java ├── parse │ ├── AttributeSerializationTest.java │ ├── ChannelAttributesPayloadSerializerTest.java │ └── ChannelViewDeserializeTest.java └── sms │ ├── model │ └── UpdateSmsChannelRequestTest.java │ └── parse │ └── UpdateSmsChannelPayloadSerializerTest.java ├── client ├── ClientExceptionTest.java ├── OAuthCredentialsTest.java ├── OAuthTokenFetcherTest.java ├── RequestErrorTest.java ├── ResponseTest.java └── UrbanAirshipClientTest.java ├── createandsend ├── CreateAndSendEmailTest.java ├── CreateAndSendScheduleTest.java └── CreateAndSendSmsTest.java ├── customevents ├── CustomEventRequestTest.java ├── model │ └── CustomEventPayloadTest.java └── parse │ ├── CustomEventPayloadSerializerTest.java │ └── CustomEventUserSerializerTest.java ├── email └── EmailAttachmentRequestTest.java ├── experiments ├── ExperimentDeleteRequestTest.java ├── ExperimentRequestTest.java ├── model │ ├── ExperimentResponseTest.java │ ├── ExperimentTest.java │ ├── VariantPushPayloadTest.java │ └── VariantTest.java └── parse │ ├── ExperimentDeserializerTest.java │ ├── ExperimentResponseDeserializerTest.java │ ├── ExperimentSerializerTest.java │ ├── VariantDeserializerTest.java │ ├── VariantPushPayloadDeserializerTest.java │ ├── VariantPushPayloadSerializerTest.java │ └── VariantSerializerTest.java ├── inbox ├── InboxBatchDeleteRequestTest.java └── InboxDeleteRequestTest.java ├── nameduser ├── NamedUserAttributePayloadTest.java ├── NamedUserListingRequestTest.java ├── NamedUserListingResponseTest.java ├── NamedUserRequestTest.java ├── NamedUserScopedRequestTest.java ├── NamedUserTagRequestTest.java ├── NamedUserUninstallRequestTest.java ├── NamedUserUpdateRequestTest.java └── NamedUserViewTest.java ├── oauth └── PublicKeyVerificationRequestTest.java ├── push ├── PushRequestTest.java ├── model │ ├── CampaignsTest.java │ ├── ChannelTypeDataTest.java │ ├── DisplayTest.java │ ├── InAppTest.java │ ├── PushExpiryTest.java │ ├── audience │ │ ├── LocationIdentifierTest │ │ │ └── LocationIdentifierTest.java │ │ ├── SelectorVisitorTest.java │ │ ├── SelectorsTest │ │ │ └── SelectorsTest.java │ │ └── location │ │ │ └── SegmentDefinitionDeserializerTest.java │ └── notification │ │ ├── NotificationTest.java │ │ ├── actions │ │ └── ActionTest.java │ │ ├── adm │ │ └── ADMDevicePayloadTest.java │ │ ├── android │ │ ├── AndroidDevicePayloadTest.java │ │ ├── PublicNotificationTest.java │ │ ├── StyleTest.java │ │ └── WearableTest.java │ │ ├── email │ │ └── EmailPayloadTest.java │ │ ├── ios │ │ ├── IOSAlertDataTest.java │ │ └── IOSDevicePayloadTest.java │ │ ├── open │ │ └── OpenPayloadTest.java │ │ ├── richpush │ │ └── RichPushMessageTest.java │ │ └── web │ │ └── WebSettingsDevicePayloadTest.java └── parse │ ├── CampaignsSerializerTest.java │ ├── ChannelTypeBasicSerializationTest.java │ ├── ChannelTypeDeserializerTest.java │ ├── DateTimeBasicSerializationTest.java │ ├── DisplayDeserializerTest.java │ ├── DisplaySerializerTest.java │ ├── InAppDeserializerTest.java │ ├── InAppSerializerTest.java │ ├── NotificationBasicSerializationTest.java │ ├── OrchestrationTest.java │ ├── PushOptionsTest.java │ ├── PushPayloadBasicSerializationTest.java │ ├── PushResponseTest.java │ ├── audience │ ├── LocationSelectorDeserializerTest.java │ ├── SelectorDeserializerTest.java │ └── SelectorSerializerTest.java │ ├── notification │ ├── InteractiveDeserializerTest.java │ ├── InteractiveSerializerTest.java │ ├── ParseActionsTest.java │ ├── actions │ │ └── ActionsSerializationTest.java │ ├── adm │ │ └── PayloadDeserializerTest.java │ ├── android │ │ ├── PayloadDeserializerTest.java │ │ ├── PayloadSerializerTest.java │ │ ├── PublicNotificationDeserializerTest.java │ │ ├── PublicNotificationSerializerTest.java │ │ ├── StyleDeserializerTest.java │ │ ├── StyleSerializerTest.java │ │ ├── WearableDeserializerTest.java │ │ └── WearableSerializerTest.java │ ├── ios │ │ ├── PayloadDeserializerTest.java │ │ └── PayloadSerializerTest.java │ ├── open │ │ └── OpenPayloadSerializerTest.java │ ├── richpush │ │ └── RichPushDeserializerTest.java │ ├── sms │ │ └── SmsPayloadSerializerTest.java │ ├── web │ │ ├── PayloadDeserializerTest.java │ │ └── PayloadSerializerTest.java │ └── wns │ │ ├── AudioDeserializerTest.java │ │ ├── BadgeDeserializerTest.java │ │ ├── BindingDeserializerTest.java │ │ ├── PayloadDeserializerTest.java │ │ ├── TileDeserializerTest.java │ │ └── ToastDeserializerTest.java │ └── richpush │ └── RichPushDevicePayloadSerializerTest.java ├── reports ├── CustomEventsDetailsListingRequestTest.java ├── DevicesReportRequestTest.java ├── ExperimentOverviewReportRequestTest.java ├── ExperimentVariantReportRequestTest.java ├── PlatformStatsRequestTest.java ├── PushInfoRequestTest.java ├── PushListingRequestTest.java ├── ResponseReportRequestTest.java ├── WebResponseReportRequestTest.java ├── model │ ├── DeviceStatsTest.java │ ├── DeviceTypeStatsTest.java │ ├── DevicesReportResponseTest.java │ ├── DevicesReportTest.java │ ├── PlatformStatsResponseTest.java │ ├── PushInfoResponseTest.java │ ├── PushListingResponseTest.java │ ├── ResponseReportResponseTest.java │ └── ResponseReportTest.java └── parse │ ├── DeviceTypeDeserializerTest.java │ ├── DeviceTypeStatsDeserializerTest.java │ ├── DevicesReportDeserializerTest.java │ ├── DevicesReportResponseDeserializerTest.java │ ├── PlatformStatsDeserializerTest.java │ ├── PlatformStatsResponseDeserializerTest.java │ ├── PushInfoResponseDeserializerTest.java │ ├── PushListingResponseDeserializerTest.java │ ├── ResponseReportDeserializerTest.java │ └── ResponseReportResponseDeserializerTest.java ├── schedule ├── ListSchedulesResponseTest.java ├── ScheduleDeleteRequestTest.java ├── ScheduleListingRequestTest.java ├── SchedulePayloadResponseDeserializerTest.java ├── SchedulePayloadResponseSerializerTest.java ├── ScheduleRequestTest.java ├── ScheduleResponseTest.java ├── ScheduleSerializerTest.java ├── ScheduleStatusRequestTest.java ├── ScheduleTest.java └── ScheduleValidatorTest.java ├── segment ├── SegmentDeleteRequestTest.java ├── SegmentListingRequestTest.java ├── SegmentLookupRequestTest.java ├── SegmentRequestTest.java ├── model │ ├── SegmentListingResponseTest.java │ ├── SegmentListingViewTest.java │ └── SegmentViewTest.java └── parse │ ├── SegmentListingViewDeserializerTest.java │ └── SegmentViewDeserializerTest.java ├── sms ├── CustomSmsResponseRequestTest.java ├── KeywordInteractionRequestTest.java └── parse │ └── CustomSmsResponseChannelSerializerTest.java ├── staticlists ├── StaticListDeleteRequestTest.java ├── StaticListDownloadRequestTest.java ├── StaticListListingRequestTest.java ├── StaticListLookupRequestTest.java ├── StaticListRequestTest.java ├── StaticListUploadRequestTest.java ├── model │ ├── StaticListListingResponseTest.java │ └── StaticListViewTest.java └── parse │ ├── StaticListListingResponseDeserializerTest.java │ └── StaticListViewDeserializerTest.java ├── subscriptionlists ├── NamedUserSubscriptionListsListingRequestTest.java └── SubscriptionListsListingRequestTest.java ├── tags ├── TagListErrorsRequestTest.java ├── TagListListingRequestTest.java ├── TagListRequestTest.java └── TagListUploadRequestTest.java └── templates ├── TemplateDeleteRequestTest.java ├── TemplateListingRequestTest.java ├── TemplatePushRequestTest.java ├── TemplateRequestTest.java ├── TemplateScheduledPushRequestTest.java ├── model ├── PartialPushPayloadTest.java ├── TemplateListingResponseTest.java ├── TemplatePushPayloadTest.java ├── TemplateResponseTest.java ├── TemplateScheduledPushPayloadTest.java ├── TemplateSelectorTest.java ├── TemplateVariableTest.java └── TemplateViewTest.java └── parse ├── PartialPushPayloadDeserializerTest.java ├── PartialPushPayloadSerializerTest.java ├── TemplatePushPayloadSerializerTest.java ├── TemplateResponseDeserializerTest.java ├── TemplateScheduledPushPayloadSerializerTest.java ├── TemplateSelectorSerializerTest.java ├── TemplateVariableDeserializerTest.java ├── TemplateVariableSerializerTest.java ├── TemplateViewDeserializerTest.java └── TemplateViewSerializerTest.java /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contribution Agreement 2 | 3 | ## What is the Contributor License Agreement, and what does it mean? 4 | 5 | The Contributor License Agreement (CLA) below is to ensure that when someone contributes code to one of our open source libraries that we have a clear record of the license to use it. This is necessary so that we can ensure to all of our customers that they can make use of our libraries and tools without worry. You retain copyright of all of your code. 6 | 7 | Please read through the agreement at the URL below. 8 | 9 | If you have questions about this agreement or why we need it please contact us at https://support.airship.com/. 10 | 11 | [Contribution Agreement](https://docs.google.com/forms/d/e/1FAIpQLScErfiz-fXSPpVZ9r8Di2Tr2xDFxt5MgzUel0__9vqUgvko7Q/viewform) -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | **All bugs, feature requests, implementation concerns or general queries should be sent to our [support team](https://support.airship.com/).** 2 | 3 | You are welcome to submit an issue here for bugs, but please also reach out to our support team as well. 4 | 5 | Before completing the form below, please check the following: 6 | 7 | - [ ] You are using the most recent version of the library. 8 | - [ ] You are using a supported version of Java for that library version. 9 | - [ ] This issue is reproducible. 10 | 11 | ## Expected Behavior 12 | 13 | 14 | ## Current Behavior 15 | 16 | 17 | ## Possible Solution 18 | 19 | 20 | ## Steps to Reproduce 21 | 22 | 23 | 1. 24 | 2. 25 | 3. 26 | 4. 27 | 28 | ## Detailed Description 29 | 30 | 31 | ## Possible Fix 32 | 33 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | **If you want your PR addressed quickly, please also reach out to our [support team](https://support.airship.com/) 2 | so we can understand when you need it reviewed and how it is impacting your use of our services.** We also generally 3 | will not release new versions of our library without new feature support, a bug fix, or a clear reason from a customer 4 | why an update is required to minimize how often other customers need to update. 5 | 6 | ### What does this do and why? 7 | Please include link to open issue if applicable. 8 | 9 | ### Additional notes for reviewers 10 | * If applicable 11 | 12 | ### Testing 13 | - [ ] If these changes added new functionality, I tested them against the live API with real auth 14 | - [ ] I wrote tests covering these changes 15 | - [ ] I ran the full test suite and it passed 16 | 17 | ### Test run results, including date and time: 18 | 19 | ### Airship Contribution Agreement 20 | [Link here](https://docs.google.com/forms/d/e/1FAIpQLScErfiz-fXSPpVZ9r8Di2Tr2xDFxt5MgzUel0__9vqUgvko7Q/viewform) 21 | 22 | - [ ] I've filled out and signed Airship's contribution agreement form. 23 | 24 | ### Screenshots 25 | * If applicable 26 | -------------------------------------------------------------------------------- /.github/SUPPORT.md: -------------------------------------------------------------------------------- 1 | # Support Requests 2 | 3 | All requests for support including implementation support and feature requests are made to the Airship support team. 4 | 5 | You can contact them by visiting https://support.airship.com/ 6 | 7 | # Documentation 8 | 9 | Documentation for the library can be found here: 10 | https://docs.airship.com/api/libraries/java/ -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /.idea 3 | /target 4 | *~ 5 | *.iml 6 | *.orig 7 | docs/_build 8 | docs/_extensions 9 | docs/_templates 10 | docs/com 11 | docs/packages.rst 12 | \#*# 13 | /example/target 14 | /example/.idea 15 | .vscode/ 16 | .settings/ 17 | .classpath 18 | .factorypath 19 | .project -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/urbanairship/java-library/966c13764ea55f8f0999aba05ae4d6716e1a1c90/.gitmodules -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Copyright 2016 Urban Airship 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /VERSION.txt: -------------------------------------------------------------------------------- 1 | 10.0.0 2 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/attributelists/parse/AttributeListsObjectMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2022. Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.attributelists.parse; 6 | 7 | import com.fasterxml.jackson.databind.ObjectMapper; 8 | import com.fasterxml.jackson.databind.module.SimpleModule; 9 | import com.fasterxml.jackson.datatype.joda.JodaModule; 10 | import com.urbanairship.api.attributelists.model.AttributeListsListingResponse; 11 | import com.urbanairship.api.attributelists.model.AttributeListsView; 12 | 13 | public class AttributeListsObjectMapper { 14 | private static final ObjectMapper MAPPER = new ObjectMapper(); 15 | private static final SimpleModule MODULE = new SimpleModule("Attribute Lists API Module"); 16 | 17 | static { 18 | MODULE.addDeserializer(AttributeListsView.class, new AttributeListsViewDeserializer()); 19 | MODULE.addDeserializer(AttributeListsListingResponse.class, new AttributeListsListingResponseDeserializer()); 20 | 21 | MAPPER.registerModule(MODULE); 22 | MAPPER.registerModule(new JodaModule()); 23 | } 24 | 25 | public static SimpleModule getModule() { 26 | return MODULE; 27 | } 28 | 29 | public static ObjectMapper getInstance() { 30 | return MAPPER; 31 | } 32 | 33 | private AttributeListsObjectMapper() { 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/channel/model/ChannelAudienceType.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.channel.model; 2 | 3 | import java.util.Optional; 4 | 5 | public enum ChannelAudienceType { 6 | IOS_CHANNEL("ios_channel"), 7 | ANDROID_CHANNEL("android_channel"), 8 | AMAZON_CHANNEL("amazon_channel"), 9 | WEB_CHANNEL("web_channel"), 10 | CHANNEL("channel"), 11 | EMAIL_ADDRESS("email_address"), 12 | NAMED_USER_ID("named_user_id"); 13 | 14 | private final String identifier; 15 | 16 | private ChannelAudienceType(String identifier) { 17 | this.identifier = identifier; 18 | } 19 | 20 | public static Optional find (String identifier) { 21 | for (ChannelAudienceType audienceType : values()) { 22 | if (audienceType.getIdentifier().equals(identifier)) { 23 | return Optional.ofNullable(audienceType); 24 | } 25 | } 26 | 27 | return Optional.empty(); 28 | } 29 | 30 | public String getIdentifier() { 31 | return identifier; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/channel/model/ChannelModelObject.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.channel.model; 2 | 3 | import com.fasterxml.jackson.databind.ObjectMapper; 4 | import com.urbanairship.api.channel.parse.ChannelObjectMapper; 5 | import com.urbanairship.api.common.model.APIModelObject; 6 | 7 | public class ChannelModelObject extends APIModelObject { 8 | private final ObjectMapper MAPPER = ChannelObjectMapper.getInstance(); 9 | @Override 10 | public String toJSON() { 11 | try { 12 | return MAPPER.writeValueAsString(this); 13 | } catch (Exception e) { 14 | return toJSON(e); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/channel/model/ChannelType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.channel.model; 6 | 7 | import java.util.Optional; 8 | 9 | /** 10 | * Enum of channel types 11 | */ 12 | public enum ChannelType { 13 | 14 | IOS("ios"), 15 | ADM("amazon"), 16 | ANDROID("android"), 17 | WEB("web"), 18 | OPEN("open"), 19 | EMAIL("email"), 20 | SMS("sms"); 21 | 22 | private final String identifier; 23 | 24 | private ChannelType() { 25 | this(null); 26 | } 27 | 28 | private ChannelType(String identifier) { 29 | this.identifier = identifier; 30 | } 31 | 32 | public static Optional find(String identifier) { 33 | for (ChannelType channelType : values()) { 34 | if (channelType.getIdentifier().equals(identifier)) { 35 | return Optional.of(channelType); 36 | } 37 | } 38 | 39 | return Optional.empty(); 40 | } 41 | 42 | public String getIdentifier() { 43 | return identifier; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/channel/model/ChannelUninstallDeviceType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2021. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.channel.model; 6 | 7 | import java.util.Optional; 8 | 9 | /** 10 | * Enum of authorized channel types for uninstall endpoint. 11 | * 12 | */ 13 | public enum ChannelUninstallDeviceType { 14 | IOS("ios"), 15 | ANDROID("android"), 16 | WEB("web"), 17 | AMAZON("amazon"), 18 | OPEN("open"); 19 | 20 | private final String identifier; 21 | 22 | private ChannelUninstallDeviceType() { 23 | this(null); 24 | } 25 | 26 | private ChannelUninstallDeviceType(String identifier) { 27 | this.identifier = identifier; 28 | } 29 | 30 | public static Optional find(String identifier) { 31 | for (ChannelUninstallDeviceType channelType : values()) { 32 | if (channelType.getIdentifier().equals(identifier)) { 33 | return Optional.of(channelType); 34 | } 35 | } 36 | 37 | return Optional.empty(); 38 | } 39 | 40 | public String getIdentifier() { 41 | return identifier; 42 | } 43 | 44 | } -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/channel/model/attributes/AttributeAction.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.channel.model.attributes; 2 | 3 | import java.util.Optional; 4 | 5 | public enum AttributeAction { 6 | SET("set"), 7 | REMOVE("remove"); 8 | 9 | private final String identifier; 10 | 11 | private AttributeAction(String identifier) { 12 | this.identifier = identifier; 13 | } 14 | 15 | public static Optional find(String identifier) { 16 | for (AttributeAction attributeAction : values()) { 17 | if (attributeAction.getIdentifier().equals(identifier)) { 18 | return Optional.of(attributeAction); 19 | } 20 | } 21 | 22 | return Optional.empty(); 23 | } 24 | 25 | public String getIdentifier() { 26 | return identifier; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/channel/model/attributes/audience/AttributeAudienceType.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.channel.model.attributes.audience; 2 | 3 | import java.util.Optional; 4 | 5 | public enum AttributeAudienceType { 6 | IOS_CHANNEL("ios_channel"), 7 | ANDROID_CHANNEL("android_channel"), 8 | AMAZON_CHANNEL("amazon_channel"), 9 | WEB_CHANNEL("web_channel"), 10 | CHANNEL("channel"), 11 | EMAIL_ADDRESS("email_address"), 12 | NAMED_USER_ID("named_user_id"); 13 | 14 | private final String identifier; 15 | 16 | private AttributeAudienceType(String identifier) { 17 | this.identifier = identifier; 18 | } 19 | 20 | public static Optional find (String identifier) { 21 | for (AttributeAudienceType audienceType : values()) { 22 | if (audienceType.getIdentifier().equals(identifier)) { 23 | return Optional.ofNullable(audienceType); 24 | } 25 | } 26 | 27 | return Optional.empty(); 28 | } 29 | 30 | public String getIdentifier() { 31 | return identifier; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/channel/model/email/OptInLevel.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.channel.model.email; 2 | 3 | import java.util.Optional; 4 | 5 | /** 6 | * Enum of opt in levels 7 | */ 8 | public enum OptInLevel { 9 | 10 | EMAIL_COMMERCIAL_OPTED_IN("commercial_opted_in"), 11 | EMAIL_COMMERCIAL_OPTED_OUT("commercial_opted_out"), 12 | EMAIL_TRANSACTIONAL_OPTED_IN("transactional_opted_in"), 13 | EMAIL_TRANSACTIONAL_OPTED_OUT("transactional_opted_out"), 14 | CREATE_AND_SEND_COMMERCIAL_OPTED_IN("ua_commercial_opted_in"), 15 | CREATE_AND_SEND_TRANSACTIONAL_OPTED_IN("ua_transactional_opted_in"), 16 | NONE("none"); 17 | 18 | private final String identifier; 19 | 20 | private OptInLevel() { 21 | this(null); 22 | } 23 | 24 | private OptInLevel(String identifier) { 25 | this.identifier = identifier; 26 | } 27 | 28 | public static Optional find(String identifier) { 29 | for (OptInLevel optInLevel : values()) { 30 | if (optInLevel.getIdentifier().equals(identifier)) { 31 | return Optional.of(optInLevel); 32 | } 33 | } 34 | 35 | return Optional.empty(); 36 | } 37 | 38 | public String getIdentifier() { 39 | return identifier; 40 | } 41 | } -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/channel/model/email/OptInMode.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.channel.model.email; 2 | 3 | import java.util.Optional; 4 | 5 | /** 6 | * Enum of opt in modes 7 | */ 8 | public enum OptInMode { 9 | 10 | CLASSIC("classic"), 11 | DOUBLE("double"); 12 | 13 | private final String identifier; 14 | 15 | private OptInMode() { 16 | this(null); 17 | } 18 | 19 | private OptInMode(String identifier) { 20 | this.identifier = identifier; 21 | } 22 | 23 | public static Optional find(String identifier) { 24 | for (OptInMode optInLevel : values()) { 25 | if (optInLevel.getIdentifier().equals(identifier)) { 26 | return Optional.of(optInLevel); 27 | } 28 | } 29 | 30 | return Optional.empty(); 31 | } 32 | 33 | public String getIdentifier() { 34 | return identifier; 35 | } 36 | } -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/channel/model/subscriptionlist/SubscriptionListAction.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.channel.model.subscriptionlist; 2 | 3 | import java.util.Optional; 4 | 5 | public enum SubscriptionListAction { 6 | SUBSCRIBE("subscribe"), 7 | UNSUBSCRIBE("unsubscribe"); 8 | 9 | private final String identifier; 10 | 11 | private SubscriptionListAction(String identifier) { 12 | this.identifier = identifier; 13 | } 14 | 15 | public static Optional find(String identifier) { 16 | for (SubscriptionListAction subscriptionListAction : values()) { 17 | if (subscriptionListAction.getIdentifier().equals(identifier)) { 18 | return Optional.of(subscriptionListAction); 19 | } 20 | } 21 | 22 | return Optional.empty(); 23 | } 24 | 25 | public String getIdentifier() { 26 | return identifier; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/channel/parse/ChannelUninstallDeviceSerializer.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.channel.parse; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.databind.JsonSerializer; 5 | import com.fasterxml.jackson.databind.SerializerProvider; 6 | import com.urbanairship.api.channel.model.ChannelUninstallDevice; 7 | 8 | import java.io.IOException; 9 | 10 | public class ChannelUninstallDeviceSerializer extends JsonSerializer { 11 | @Override 12 | public void serialize(ChannelUninstallDevice ChannelUninstallDevice, JsonGenerator jgen, SerializerProvider provider) throws IOException { 13 | jgen.writeStartObject(); 14 | 15 | jgen.writeObjectField("channel_id", ChannelUninstallDevice.getChannelId()); 16 | jgen.writeObjectField("device_type", ChannelUninstallDevice.getChannelType().getIdentifier()); 17 | 18 | jgen.writeEndObject(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/channel/parse/attributes/AttributeSerializer.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.channel.parse.attributes; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.databind.JsonSerializer; 5 | import com.fasterxml.jackson.databind.SerializerProvider; 6 | import com.urbanairship.api.channel.Constants; 7 | import com.urbanairship.api.channel.model.attributes.Attribute; 8 | import com.urbanairship.api.common.parse.DateFormats; 9 | 10 | import java.io.IOException; 11 | 12 | public class AttributeSerializer extends JsonSerializer { 13 | 14 | @Override 15 | public void serialize(Attribute attribute, JsonGenerator jgen, SerializerProvider provider) throws IOException { 16 | jgen.writeStartObject(); 17 | 18 | jgen.writeStringField(Constants.KEY, attribute.getKey()); 19 | jgen.writeStringField(Constants.ACTION, attribute.getAction().getIdentifier()); 20 | 21 | if (attribute.getTimeStamp().isPresent()) { 22 | jgen.writeStringField(Constants.TIMESTAMP, DateFormats.DATE_FORMATTER.print(attribute.getTimeStamp().get())); 23 | } 24 | 25 | if (attribute.getValue().isPresent()) { 26 | jgen.writeObjectField(Constants.VALUE, attribute.getValue().get()); 27 | } 28 | 29 | jgen.writeEndObject(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/channel/parse/attributes/ChannelAttributesPayloadSerializer.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.channel.parse.attributes; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.databind.JsonSerializer; 5 | import com.fasterxml.jackson.databind.SerializerProvider; 6 | import com.urbanairship.api.channel.model.attributes.Attribute; 7 | import com.urbanairship.api.channel.model.attributes.ChannelAttributesPayload; 8 | 9 | import java.io.IOException; 10 | 11 | public class ChannelAttributesPayloadSerializer extends JsonSerializer { 12 | @Override 13 | public void serialize(ChannelAttributesPayload payload, JsonGenerator jgen, SerializerProvider provider) throws IOException { 14 | jgen.writeStartObject(); 15 | 16 | jgen.writeObjectField("audience", payload.getAudience()); 17 | 18 | jgen.writeArrayFieldStart("attributes"); 19 | 20 | for (Attribute attribute : payload.getAttributes()) { 21 | jgen.writeObject(attribute); 22 | } 23 | 24 | jgen.writeEndArray(); 25 | 26 | jgen.writeEndObject(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/channel/parse/email/UninstallEmailChannelSerializer.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.channel.parse.email; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.core.JsonProcessingException; 5 | import com.fasterxml.jackson.databind.JsonSerializer; 6 | import com.fasterxml.jackson.databind.SerializerProvider; 7 | import com.urbanairship.api.channel.Constants; 8 | import com.urbanairship.api.channel.model.email.UninstallEmailChannel; 9 | 10 | import java.io.IOException; 11 | 12 | public class UninstallEmailChannelSerializer extends JsonSerializer { 13 | 14 | @Override 15 | public void serialize(UninstallEmailChannel payload, JsonGenerator jgen, 16 | SerializerProvider serializerProvider) throws IOException, JsonProcessingException { 17 | jgen.writeStartObject(); 18 | 19 | jgen.writeStringField(Constants.EMAIL_ADDRESS, payload.getEmailAddress()); 20 | 21 | jgen.writeEndObject(); 22 | } 23 | } -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/channel/parse/email/UpdateEmailChannelResponseReader.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.channel.parse.email; 2 | 3 | import com.fasterxml.jackson.core.JsonParser; 4 | import com.urbanairship.api.channel.model.email.EmailChannelResponse; 5 | import com.urbanairship.api.common.parse.APIParsingException; 6 | import com.urbanairship.api.common.parse.JsonObjectReader; 7 | 8 | import java.io.IOException; 9 | 10 | public class UpdateEmailChannelResponseReader implements JsonObjectReader { 11 | 12 | private final EmailChannelResponse.Builder builder; 13 | 14 | public UpdateEmailChannelResponseReader() { 15 | this.builder = EmailChannelResponse.newBuilder(); 16 | } 17 | 18 | public void readOk(JsonParser jsonParser) throws IOException { 19 | builder.setOk(jsonParser.getBooleanValue()); 20 | } 21 | 22 | public void readChannelId(JsonParser jsonParser) throws IOException { 23 | builder.setChannelId(jsonParser.readValueAs(String.class)); 24 | } 25 | 26 | @Override 27 | public EmailChannelResponse validateAndBuild() throws IOException { 28 | try { 29 | return builder.build(); 30 | } catch (Exception ex) { 31 | throw new APIParsingException(ex.getMessage()); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/channel/parse/ios/QuietTimeReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.channel.parse.ios; 6 | 7 | import com.fasterxml.jackson.core.JsonParser; 8 | import com.urbanairship.api.channel.model.ios.QuietTime; 9 | import com.urbanairship.api.common.parse.APIParsingException; 10 | import com.urbanairship.api.common.parse.JsonObjectReader; 11 | 12 | import java.io.IOException; 13 | 14 | public final class QuietTimeReader implements JsonObjectReader { 15 | 16 | private final QuietTime.Builder builder; 17 | 18 | public QuietTimeReader() { 19 | this.builder = QuietTime.newBuilder(); 20 | } 21 | 22 | public void readStart(JsonParser jsonParser) throws IOException { 23 | builder.setStart(jsonParser.readValueAs(String.class)); 24 | } 25 | 26 | public void readEnd(JsonParser jsonParser) throws IOException { 27 | builder.setEnd(jsonParser.readValueAs(String.class)); 28 | } 29 | 30 | @Override 31 | public QuietTime validateAndBuild() throws IOException { 32 | try { 33 | return builder.build(); 34 | } catch (Exception e) { 35 | throw new APIParsingException(e.getMessage()); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/channel/parse/open/OpenChannelSerializer.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.channel.parse.open; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.databind.JsonSerializer; 5 | import com.fasterxml.jackson.databind.SerializerProvider; 6 | import com.urbanairship.api.channel.Constants; 7 | import com.urbanairship.api.channel.model.open.OpenChannel; 8 | 9 | import java.io.IOException; 10 | 11 | public class OpenChannelSerializer extends JsonSerializer { 12 | 13 | @Override 14 | public void serialize(OpenChannel openChannel, JsonGenerator jgen, SerializerProvider provider) throws IOException { 15 | jgen.writeStartObject(); 16 | 17 | jgen.writeStringField(Constants.OPEN_PLATFORM_NAME, openChannel.getOpenPlatformName()); 18 | 19 | if (openChannel.getOldAddress().isPresent()) { 20 | jgen.writeStringField(Constants.OLD_ADDRESS, openChannel.getOldAddress().get()); 21 | } 22 | 23 | if (openChannel.getIdentifiers().isPresent()) { 24 | jgen.writeObjectField(Constants.IDENTIFIERS, openChannel.getIdentifiers().get()); 25 | } 26 | 27 | jgen.writeEndObject(); 28 | } 29 | } -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/channel/parse/subscriptionlist/SubscriptionListPayloadSerializer.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.channel.parse.subscriptionlist; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.databind.JsonSerializer; 5 | import com.fasterxml.jackson.databind.SerializerProvider; 6 | import com.urbanairship.api.channel.model.subscriptionlist.SubscriptionList; 7 | import com.urbanairship.api.channel.model.subscriptionlist.SubscriptionListPayload; 8 | 9 | import java.io.IOException; 10 | 11 | public class SubscriptionListPayloadSerializer extends JsonSerializer { 12 | @Override 13 | public void serialize(SubscriptionListPayload payload, JsonGenerator jgen, SerializerProvider provider) throws IOException { 14 | jgen.writeStartObject(); 15 | 16 | jgen.writeObjectField("audience", payload.getAudience()); 17 | 18 | jgen.writeArrayFieldStart("subscription_lists"); 19 | 20 | for (SubscriptionList subscriptionList : payload.getSubscriptionList()) { 21 | jgen.writeStartObject(); 22 | jgen.writeStringField("action", subscriptionList.getAction().getIdentifier()); 23 | jgen.writeStringField("list_id", subscriptionList.getListId()); 24 | jgen.writeEndObject(); 25 | } 26 | 27 | jgen.writeEndArray(); 28 | 29 | jgen.writeEndObject(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/channel/parse/web/SubscriptionReader.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.channel.parse.web; 2 | 3 | import com.fasterxml.jackson.core.JsonParser; 4 | import com.urbanairship.api.channel.Constants; 5 | import com.urbanairship.api.channel.model.web.Subscription; 6 | import com.urbanairship.api.common.parse.APIParsingException; 7 | import com.urbanairship.api.common.parse.JsonObjectReader; 8 | import com.urbanairship.api.common.parse.StringFieldDeserializer; 9 | 10 | import java.io.IOException; 11 | 12 | public class SubscriptionReader implements JsonObjectReader { 13 | private final Subscription.Builder builder; 14 | 15 | public SubscriptionReader() { 16 | this.builder = Subscription.newBuilder(); 17 | } 18 | 19 | public void readAuth(JsonParser jsonParser) throws IOException { 20 | builder.setAuth(StringFieldDeserializer.INSTANCE.deserialize(jsonParser, Constants.AUTH)); 21 | } 22 | 23 | public void readP256dh(JsonParser jsonParser) throws IOException { 24 | builder.setP256dh(StringFieldDeserializer.INSTANCE.deserialize(jsonParser, Constants.P256DH)); 25 | } 26 | 27 | public Subscription validateAndBuild() throws IOException { 28 | try { 29 | return builder.build(); 30 | } catch (Exception e) { 31 | throw new APIParsingException(e.getMessage()); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/channel/parse/web/WebSettingsReader.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.channel.parse.web; 2 | 3 | import com.fasterxml.jackson.core.JsonParser; 4 | import com.urbanairship.api.channel.model.web.Subscription; 5 | import com.urbanairship.api.channel.model.web.WebSettings; 6 | import com.urbanairship.api.common.parse.APIParsingException; 7 | import com.urbanairship.api.common.parse.JsonObjectReader; 8 | 9 | import java.io.IOException; 10 | 11 | public class WebSettingsReader implements JsonObjectReader { 12 | 13 | private final WebSettings.Builder builder; 14 | 15 | public WebSettingsReader() { 16 | this.builder = WebSettings.newBuilder(); 17 | } 18 | 19 | public void readSubscription(JsonParser parser) throws IOException { 20 | builder.setSubscription(parser.readValueAs(Subscription.class)); 21 | } 22 | 23 | public WebSettings validateAndBuild() throws IOException { 24 | try { 25 | return builder.build(); 26 | } catch (Exception e) { 27 | throw new APIParsingException(e.getMessage(), e); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/client/Request.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.client; 6 | 7 | import org.apache.http.entity.ContentType; 8 | 9 | import java.net.URI; 10 | import java.net.URISyntaxException; 11 | import java.util.Map; 12 | 13 | /** 14 | * The base interface for UrbanAirshipClient API requests 15 | */ 16 | 17 | public interface Request { 18 | 19 | public final static String CONTENT_TYPE_TEXT_CSV = "text/csv"; 20 | public final static String CONTENT_TYPE_JSON = "application/json"; 21 | public final static String CONTENT_ENCODING_GZIP = "gzip"; 22 | public final static String UA_VERSION_JSON = "application/vnd.urbanairship+json; version=3"; 23 | public final static String UA_VERSION_CSV = "application/vnd.urbanairship+csv; version=3"; 24 | 25 | public static enum HttpMethod { 26 | GET, 27 | POST, 28 | PUT, 29 | DELETE, 30 | } 31 | 32 | HttpMethod getHttpMethod(); 33 | 34 | String getRequestBody(); 35 | 36 | ContentType getContentType(); 37 | 38 | Map getRequestHeaders(); 39 | 40 | URI getUri(URI baseUri) throws URISyntaxException; 41 | 42 | ResponseParser getResponseParser(); 43 | 44 | boolean bearerTokenAuthRequired(); 45 | 46 | boolean canUseBearerTokenAuth(); 47 | } -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/client/RequestClient.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.client; 2 | 3 | import java.io.Closeable; 4 | import java.util.Map; 5 | import java.util.concurrent.Future; 6 | 7 | /** 8 | * RequestClient must be implemented to create a custom HTTP client that is then used by UrbanAirshipClient to make requests. 9 | */ 10 | public interface RequestClient extends Closeable { 11 | /** 12 | * Executes the HTTP request. 13 | * @param request the Request. 14 | * @param callback the ResponseCallback. 15 | * @param headers a Map of the headers. 16 | * @param type 17 | * @return The Future Response. 18 | */ 19 | public Future executeAsync(final Request request, final ResponseCallback callback, Map headers); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/client/RequestUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.client; 6 | 7 | import com.fasterxml.jackson.databind.ObjectMapper; 8 | import com.urbanairship.api.common.model.GenericResponse; 9 | 10 | import java.net.URI; 11 | import java.net.URISyntaxException; 12 | 13 | public class RequestUtils { 14 | 15 | private final static ObjectMapper mapper = new ObjectMapper(); 16 | public final static ResponseParser GENERIC_RESPONSE_PARSER = response -> mapper.readValue(response, GenericResponse.class); 17 | 18 | /** 19 | * A method to resolve base URIs without excluding the original path. 20 | * @param baseURI URI 21 | * @param path String 22 | * @return URI 23 | */ 24 | public static URI resolveURI(URI baseURI, String path) { 25 | URI uri = baseURI; 26 | 27 | if (!uri.getPath().endsWith("/")) { 28 | try { 29 | uri = new URI(uri.toString() + "/"); 30 | } catch (URISyntaxException e) { 31 | throw new RuntimeException(e); 32 | } 33 | } 34 | if (path.startsWith("/")) { 35 | path = path.substring(1); 36 | } 37 | 38 | return uri.resolve(path); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/client/ResponseCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.client; 6 | 7 | /** 8 | * Interface providing callback methods for the response processing lifecycle. 9 | */ 10 | public interface ResponseCallback { 11 | 12 | /** 13 | * Callback for when a response has been completely processed. 14 | * 15 | * @param response A Response instance. 16 | */ 17 | public void completed(Response response); 18 | 19 | /** 20 | * Callback for when an error occurs in response processing and a Throwable is thrown. 21 | * 22 | * @param throwable A Throwable instance. 23 | */ 24 | public void error(Throwable throwable); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/client/ResponseParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.client; 6 | 7 | import java.io.IOException; 8 | 9 | public interface ResponseParser { 10 | T parse(String response) throws IOException; 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/client/parse/OAuthTokenResponse.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.client.parse; 2 | 3 | public class OAuthTokenResponse { 4 | private String accessToken; 5 | private long expiresIn; 6 | private long tokenAcquiredAt; 7 | private long tokenExpiresAt; 8 | 9 | public OAuthTokenResponse(String accessToken, long expiresIn) { 10 | this.accessToken = accessToken; 11 | this.expiresIn = expiresIn; 12 | this.tokenAcquiredAt = System.currentTimeMillis(); 13 | this.tokenExpiresAt = this.tokenAcquiredAt + (this.expiresIn * 1000); 14 | } 15 | 16 | public String getAccessToken() { 17 | return accessToken; 18 | } 19 | 20 | public long getExpiresIn() { 21 | return expiresIn; 22 | } 23 | 24 | public long getTokenAcquiredAt() { 25 | return tokenAcquiredAt; 26 | } 27 | 28 | public long getTokenExpiresAt() { 29 | return tokenExpiresAt; 30 | } 31 | 32 | public boolean isTokenExpired() { 33 | return System.currentTimeMillis() >= tokenExpiresAt; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/common/CSVUtils.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.common; 2 | 3 | public class CSVUtils { 4 | 5 | /** 6 | * Formats an array of strings as a single CSV row. 7 | * 8 | * @param columns Array of strings representing the columns of the CSV row. 9 | * @return A formatted CSV row as a String. 10 | */ 11 | public static String formatRowForCSV(String[] columns) { 12 | StringBuilder sb = new StringBuilder(); 13 | for (int i = 0; i < columns.length; i++) { 14 | if (i > 0) { 15 | sb.append(","); 16 | } 17 | String column = columns[i]; 18 | sb.append(column); 19 | } 20 | return sb.toString(); 21 | } 22 | } -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/common/model/APIModelObject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.common.model; 6 | 7 | import com.urbanairship.api.common.parse.CommonObjectMapper; 8 | 9 | import java.io.IOException; 10 | 11 | public abstract class APIModelObject { 12 | public String toJSON() { 13 | try { 14 | return CommonObjectMapper.getInstance().writeValueAsString(this); 15 | } catch ( IOException e) { 16 | return toJSON(e); 17 | } 18 | } 19 | 20 | protected static String toJSON(Exception e) { 21 | return "{ \"exception\" : \"" + e.getClass().getName() + "\", \"message\" : \"" + e.getMessage() + "\" }"; 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/common/parse/BooleanFieldDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.common.parse; 6 | 7 | 8 | import com.fasterxml.jackson.core.JsonParser; 9 | import com.fasterxml.jackson.core.JsonToken; 10 | 11 | import java.io.IOException; 12 | 13 | public class BooleanFieldDeserializer { 14 | 15 | public static final BooleanFieldDeserializer INSTANCE = new BooleanFieldDeserializer(); 16 | 17 | private BooleanFieldDeserializer() { } 18 | 19 | public boolean deserialize(JsonParser parser, String fieldName) throws IOException { 20 | JsonToken token = parser.getCurrentToken(); 21 | if ((token != JsonToken.VALUE_TRUE) && (token != JsonToken.VALUE_FALSE)) { 22 | throw new APIParsingException(String.format("\"%s\" field is expected to be a boolean value (true/false).", fieldName)); 23 | } 24 | return parser.getValueAsBoolean(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/common/parse/CommonObjectMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.common.parse; 6 | 7 | import com.fasterxml.jackson.databind.DeserializationFeature; 8 | import com.fasterxml.jackson.databind.ObjectMapper; 9 | import com.fasterxml.jackson.databind.module.SimpleModule; 10 | import org.joda.time.DateTime; 11 | 12 | public class CommonObjectMapper { 13 | 14 | private static final ObjectMapper MAPPER = new ObjectMapper(); 15 | private static final SimpleModule MODULE = new SimpleModule("Common API Module"); 16 | static { 17 | MODULE 18 | .addSerializer(DateTime.class, new DateTimeSerializer()) 19 | .addDeserializer(DateTime.class, new DateTimeDeserializer()); 20 | 21 | MAPPER.registerModule(MODULE); 22 | MAPPER.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); 23 | } 24 | 25 | public static SimpleModule getModule() { 26 | return MODULE; 27 | } 28 | 29 | public static ObjectMapper getInstance() { 30 | return MAPPER; 31 | } 32 | 33 | private CommonObjectMapper() { } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/common/parse/DateTimeDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.common.parse; 6 | 7 | import com.fasterxml.jackson.core.JsonParser; 8 | import com.fasterxml.jackson.databind.DeserializationContext; 9 | import com.fasterxml.jackson.databind.JsonDeserializer; 10 | import org.joda.time.DateTime; 11 | 12 | import java.io.IOException; 13 | 14 | public class DateTimeDeserializer extends JsonDeserializer { 15 | 16 | @Override 17 | public DateTime deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { 18 | String dateString = jp.getText(); 19 | try { 20 | return DateFormats.DATE_PARSER.parseDateTime(dateString); 21 | } 22 | catch (Exception e) { 23 | throw new APIParsingException(String.format("Date string %s is not in accepted ISO 8601 UTC date format", dateString)); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/common/parse/DateTimeSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.common.parse; 6 | 7 | import com.fasterxml.jackson.core.JsonGenerator; 8 | import com.fasterxml.jackson.databind.JsonSerializer; 9 | import com.fasterxml.jackson.databind.SerializerProvider; 10 | import org.joda.time.DateTime; 11 | 12 | import java.io.IOException; 13 | 14 | public class DateTimeSerializer extends JsonSerializer { 15 | 16 | @Override 17 | public void serialize(DateTime value, JsonGenerator jgen, SerializerProvider provider) throws IOException { 18 | jgen.writeString(DateFormats.DATE_FORMATTER.print(value)); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/common/parse/FieldParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.common.parse; 6 | 7 | 8 | import com.fasterxml.jackson.core.JsonParser; 9 | import com.fasterxml.jackson.databind.DeserializationContext; 10 | 11 | import java.io.IOException; 12 | 13 | public interface FieldParser { 14 | 15 | void parse(T reader, JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/common/parse/FieldParserRegistry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.common.parse; 6 | 7 | import java.util.Optional; 8 | 9 | public interface FieldParserRegistry> { 10 | 11 | Optional> getFieldParser(String fieldName); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/common/parse/IntFieldDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.common.parse; 6 | 7 | 8 | import com.fasterxml.jackson.core.JsonParser; 9 | import com.fasterxml.jackson.core.JsonToken; 10 | 11 | import java.io.IOException; 12 | 13 | public class IntFieldDeserializer { 14 | 15 | public static final IntFieldDeserializer INSTANCE = new IntFieldDeserializer(); 16 | 17 | private IntFieldDeserializer() { } 18 | 19 | public int deserialize(JsonParser parser, String fieldName) throws IOException { 20 | JsonToken token = parser.getCurrentToken(); 21 | if (token != JsonToken.VALUE_NUMBER_INT) { 22 | throw new APIParsingException(String.format("\"%s\" field is expected to be an integer.", fieldName)); 23 | } 24 | return parser.getValueAsInt(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/common/parse/JsonObjectReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.common.parse; 6 | 7 | import java.io.IOException; 8 | 9 | public interface JsonObjectReader { 10 | 11 | T validateAndBuild() throws IOException; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/common/parse/ListOfStringsDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.common.parse; 6 | 7 | 8 | import com.fasterxml.jackson.core.JsonParser; 9 | import com.fasterxml.jackson.core.type.TypeReference; 10 | 11 | import java.io.IOException; 12 | import java.util.List; 13 | 14 | public class ListOfStringsDeserializer { 15 | 16 | public static final ListOfStringsDeserializer INSTANCE = new ListOfStringsDeserializer(); 17 | 18 | private ListOfStringsDeserializer() { } 19 | 20 | public List deserialize(JsonParser parser, String fieldName) { 21 | try { 22 | return parser.readValueAs(new TypeReference>() {}); 23 | } 24 | catch (IOException e) { 25 | throw new APIParsingException(String.format("%s must be an array of simple strings", fieldName)); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/common/parse/MapFieldParserRegistry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.common.parse; 6 | 7 | import java.util.Map; 8 | import java.util.Optional; 9 | 10 | public class MapFieldParserRegistry> implements FieldParserRegistry { 11 | 12 | private final Map> registryMap; 13 | private final Optional> defaultParser; 14 | 15 | public MapFieldParserRegistry(Map> registryMap) { 16 | this(registryMap, null); 17 | } 18 | 19 | public MapFieldParserRegistry(Map> registryMap, FieldParser defaultParser) { 20 | this.registryMap = registryMap; 21 | this.defaultParser = Optional.ofNullable(defaultParser); 22 | } 23 | 24 | @Override 25 | public Optional> getFieldParser(String fieldName) { 26 | FieldParser parser = registryMap.get(fieldName); 27 | if (parser == null && defaultParser.isPresent()) { 28 | return defaultParser; 29 | } 30 | 31 | return Optional.ofNullable(registryMap.get(fieldName)); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/common/parse/MapOfStringsDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.common.parse; 6 | 7 | 8 | import com.fasterxml.jackson.core.JsonParser; 9 | import com.fasterxml.jackson.core.type.TypeReference; 10 | 11 | import java.io.IOException; 12 | import java.util.Map; 13 | 14 | public class MapOfStringsDeserializer { 15 | 16 | public static final MapOfStringsDeserializer INSTANCE = new MapOfStringsDeserializer(); 17 | 18 | private MapOfStringsDeserializer() { } 19 | 20 | public Map deserialize(JsonParser parser, String fieldName) throws APIParsingException { 21 | try { 22 | return parser.readValueAs(new TypeReference>() {}); 23 | } 24 | catch (IOException e) { 25 | APIParsingException.raise(String.format("%s must contain simple strings as keys/values", fieldName), parser); 26 | } 27 | // Satisfy the java compiler - it can't figure out that 28 | // APIParsingException.raise() always throws. 29 | return null; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/common/parse/StringFieldDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.common.parse; 6 | 7 | 8 | import com.fasterxml.jackson.core.JsonParser; 9 | import com.fasterxml.jackson.core.JsonToken; 10 | 11 | import java.io.IOException; 12 | 13 | public class StringFieldDeserializer { 14 | 15 | public static final StringFieldDeserializer INSTANCE = new StringFieldDeserializer(); 16 | 17 | private StringFieldDeserializer() { } 18 | 19 | public String deserialize(JsonParser parser, String fieldName) throws IOException { 20 | JsonToken token = parser.getCurrentToken(); 21 | if (token != JsonToken.VALUE_STRING) { 22 | APIParsingException.raise(String.format("\"%s\" field is expected to be a string", fieldName), parser); 23 | } 24 | 25 | return parser.getText(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/createandsend/model/audience/email/EmailOptInType.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.createandsend.model.audience.email; 2 | 3 | 4 | import java.util.Optional; 5 | 6 | public enum EmailOptInType { 7 | COMMERCIAL_OPTED_IN("ua_commercial_opted_in"), 8 | TRANSACTIONAL_OPTED_IN("ua_transactional_opted_in"); 9 | 10 | private final String identifier; 11 | 12 | private EmailOptInType(String identifier) { 13 | this.identifier = identifier; 14 | } 15 | 16 | public String getIdentifier() { 17 | return identifier; 18 | } 19 | 20 | public static Optional find (String identifier) { 21 | for (EmailOptInType optInType : values()) { 22 | if (optInType.getIdentifier().equals(identifier)) { 23 | return Optional.of(optInType); 24 | } 25 | } 26 | return Optional.empty(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/createandsend/parse/CreateAndSendEmailChannelSerializer.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.createandsend.parse; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.databind.JsonSerializer; 5 | import com.fasterxml.jackson.databind.SerializerProvider; 6 | import com.urbanairship.api.common.parse.DateFormats; 7 | import com.urbanairship.api.createandsend.model.audience.email.EmailChannel; 8 | 9 | import java.io.IOException; 10 | 11 | public class CreateAndSendEmailChannelSerializer extends JsonSerializer { 12 | 13 | @Override 14 | public void serialize(EmailChannel payload, JsonGenerator jgen, SerializerProvider serializerProvider) throws IOException { 15 | 16 | jgen.writeStartObject(); 17 | jgen.writeStringField("ua_address", payload.getUaAddress()); 18 | 19 | if (payload.getCommercialOptedIn().isPresent()) { 20 | jgen.writeStringField("ua_commercial_opted_in", DateFormats.DATE_FORMATTER.print(payload.getCommercialOptedIn().get())); 21 | } else if (payload.getTransactionalOptedIn().isPresent()) { 22 | jgen.writeStringField("ua_transactional_opted_in", DateFormats.DATE_FORMATTER.print(payload.getTransactionalOptedIn().get())); 23 | } 24 | jgen.writeEndObject(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/createandsend/parse/notification/CreateAndSendPayloadSerializer.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.createandsend.parse.notification; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.databind.JsonSerializer; 5 | import com.fasterxml.jackson.databind.SerializerProvider; 6 | import com.urbanairship.api.createandsend.model.notification.CreateAndSendPayload; 7 | 8 | import java.io.IOException; 9 | 10 | public class CreateAndSendPayloadSerializer extends JsonSerializer { 11 | @Override 12 | public void serialize(CreateAndSendPayload payload, JsonGenerator jgen, SerializerProvider serializerProvider) throws IOException { 13 | jgen.writeStartObject(); 14 | 15 | jgen.writeObjectField("audience", payload.getAudience()); 16 | jgen.writeObjectField("device_types", payload.getNotification().getDeviceTypePayloadOverrides().keySet().toArray()); 17 | jgen.writeObjectField("notification", payload.getNotification()); 18 | 19 | if (payload.getCampaigns().isPresent()) { 20 | jgen.writeObjectField("campaigns", payload.getCampaigns().get()); 21 | } 22 | 23 | if (!payload.getGlobalAttributes().get().isEmpty()) { 24 | jgen.writeObjectField("global_attributes", payload.getGlobalAttributes().get()); 25 | } 26 | 27 | jgen.writeEndObject(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/createandsend/parse/notification/CreateAndSendSchedulePayloadSerializer.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.createandsend.parse.notification; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.databind.JsonSerializer; 5 | import com.fasterxml.jackson.databind.SerializerProvider; 6 | import com.urbanairship.api.createandsend.model.notification.CreateAndSendSchedulePayload; 7 | 8 | import java.io.IOException; 9 | 10 | public class CreateAndSendSchedulePayloadSerializer extends JsonSerializer { 11 | @Override 12 | public void serialize(CreateAndSendSchedulePayload payload, JsonGenerator jgen, SerializerProvider serializerProvider) throws IOException { 13 | jgen.writeStartObject(); 14 | 15 | jgen.writeObjectFieldStart("schedule"); 16 | jgen.writePOJOField("scheduled_time", payload.getScheduleTime()); 17 | jgen.writeEndObject(); 18 | 19 | if (payload.getName().isPresent()) { 20 | jgen.writeStringField("name", payload.getName().get()); 21 | } 22 | 23 | jgen.writeObjectField("push", payload.getPayload()); 24 | 25 | jgen.writeEndObject(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/createandsend/parse/notification/email/EmailFieldsSerializer.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.createandsend.parse.notification.email; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.databind.JsonSerializer; 5 | import com.fasterxml.jackson.databind.SerializerProvider; 6 | import com.urbanairship.api.createandsend.model.notification.email.EmailFields; 7 | 8 | import java.io.IOException; 9 | 10 | public class EmailFieldsSerializer extends JsonSerializer { 11 | @Override 12 | public void serialize(EmailFields emailFields, JsonGenerator jgen, SerializerProvider provider) throws IOException { 13 | jgen.writeStartObject(); 14 | 15 | jgen.writeStringField("plaintext_body", emailFields.getPlainTextBody()); 16 | jgen.writeStringField("subject", emailFields.getSubject()); 17 | 18 | jgen.writeEndObject(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/createandsend/parse/notification/email/VariableDetailSerializer.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.createandsend.parse.notification.email; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.databind.JsonSerializer; 5 | import com.fasterxml.jackson.databind.SerializerProvider; 6 | import com.urbanairship.api.createandsend.model.notification.email.VariableDetail; 7 | 8 | import java.io.IOException; 9 | 10 | public class VariableDetailSerializer extends JsonSerializer { 11 | @Override 12 | public void serialize(VariableDetail variableDetail, JsonGenerator jgen, SerializerProvider provider) throws IOException { 13 | jgen.writeStartObject(); 14 | 15 | if (variableDetail.getDefaultValue().isPresent()) { 16 | jgen.writeStringField("defaul_value", variableDetail.getDefaultValue().get()); 17 | } 18 | 19 | if (variableDetail.getKey().isPresent()) { 20 | jgen.writeStringField("key", variableDetail.getKey().get()); 21 | } 22 | 23 | jgen.writeEndObject(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/createandsend/parse/notification/sms/SmsFieldsSerializer.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.createandsend.parse.notification.sms; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.databind.JsonSerializer; 5 | import com.fasterxml.jackson.databind.SerializerProvider; 6 | import com.urbanairship.api.createandsend.model.notification.sms.SmsFields; 7 | 8 | import java.io.IOException; 9 | 10 | public class SmsFieldsSerializer extends JsonSerializer { 11 | 12 | @Override 13 | public void serialize(SmsFields smsFields, JsonGenerator jgen, SerializerProvider provider) throws IOException { 14 | jgen.writeStartObject(); 15 | 16 | if (smsFields.getAlert().isPresent()) { 17 | jgen.writeStringField("alert", smsFields.getAlert().get()); 18 | } 19 | 20 | jgen.writeEndObject(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/createandsend/parse/notification/sms/SmsPayloadSerializer.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.createandsend.parse.notification.sms; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.databind.JsonSerializer; 5 | import com.fasterxml.jackson.databind.SerializerProvider; 6 | import com.urbanairship.api.createandsend.model.notification.sms.SmsPayload; 7 | 8 | import java.io.IOException; 9 | 10 | public class SmsPayloadSerializer extends JsonSerializer { 11 | 12 | @Override 13 | public void serialize(SmsPayload smsPayload, JsonGenerator jgen, SerializerProvider provider) throws IOException { 14 | jgen.writeStartObject(); 15 | 16 | if (smsPayload.getAlert().isPresent()) { 17 | jgen.writeStringField("alert", smsPayload.getAlert().get()); 18 | 19 | if (smsPayload.getPushExpiry().isPresent()) { 20 | jgen.writeObjectField("expiry", smsPayload.getPushExpiry().get()); 21 | } 22 | } else if (smsPayload.getSmsTemplate().isPresent()) { 23 | jgen.writeObjectField("template", smsPayload.getSmsTemplate().get()); 24 | 25 | if (smsPayload.getPushExpiry().isPresent()) { 26 | jgen.writeObjectField("expiry", smsPayload.getPushExpiry().get()); 27 | } 28 | } 29 | 30 | jgen.writeEndObject(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/createandsend/parse/notification/sms/SmsTemplateSerializer.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.createandsend.parse.notification.sms; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.databind.JsonSerializer; 5 | import com.fasterxml.jackson.databind.SerializerProvider; 6 | import com.urbanairship.api.createandsend.model.notification.sms.SmsTemplate; 7 | 8 | import java.io.IOException; 9 | 10 | public class SmsTemplateSerializer extends JsonSerializer { 11 | @Override 12 | public void serialize(SmsTemplate smsTemplate, JsonGenerator jgen, SerializerProvider provider) throws IOException { 13 | jgen.writeStartObject(); 14 | 15 | if (smsTemplate.getSmsFields().isPresent()) { 16 | jgen.writeObjectField("fields", smsTemplate.getSmsFields().get()); 17 | } 18 | 19 | if (smsTemplate.getTemplateId().isPresent()) { 20 | jgen.writeStringField("template_id", smsTemplate.getTemplateId().get()); 21 | } 22 | 23 | jgen.writeEndObject(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/customevents/model/CustomEventChannelType.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.customevents.model; 2 | 3 | import java.util.Optional; 4 | 5 | public enum CustomEventChannelType { 6 | IOS_CHANNEL("ios_channel"), 7 | ANDROID_CHANNEL("android_channel"), 8 | AMAZON_CHANNEL("amazon_channel"), 9 | GENERIC_CHANNEL("channel"), 10 | WEB_CHANNEL("web_channel"); 11 | 12 | private final String identifier; 13 | 14 | private CustomEventChannelType() { 15 | this(null); 16 | } 17 | 18 | private CustomEventChannelType(String identifier) { 19 | this.identifier = identifier; 20 | } 21 | 22 | public static Optional find(String identifier) { 23 | for (CustomEventChannelType customEventChannelType : values()) { 24 | if (customEventChannelType.getIdentifier().equals(identifier)) { 25 | return Optional.of(customEventChannelType); 26 | } 27 | } 28 | 29 | return Optional.empty(); 30 | } 31 | 32 | public String getIdentifier() { 33 | return identifier; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/customevents/parse/CustomEventSerializer.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.customevents.parse; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.databind.JsonSerializer; 5 | import com.fasterxml.jackson.databind.SerializerProvider; 6 | import com.urbanairship.api.customevents.model.CustomEventPayload; 7 | 8 | import java.io.IOException; 9 | 10 | public class CustomEventSerializer extends JsonSerializer { 11 | 12 | @Override 13 | public void serialize(CustomEventPayload event, JsonGenerator jgen, SerializerProvider provider) throws IOException { 14 | jgen.writeStartObject(); 15 | if (event.getOccurred().isPresent()) { 16 | jgen.writeObjectField("occurred", event.getOccurred()); 17 | } 18 | jgen.writeObjectField("user", event.getCustomEventUser()); 19 | jgen.writeObjectField("body", event.getCustomEventBody()); 20 | 21 | jgen.writeEndObject(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/customevents/parse/CustomEventUserSerializer.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.customevents.parse; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.databind.JsonSerializer; 5 | import com.fasterxml.jackson.databind.SerializerProvider; 6 | import com.urbanairship.api.customevents.model.CustomEventUser; 7 | 8 | import java.io.IOException; 9 | 10 | public class CustomEventUserSerializer extends JsonSerializer { 11 | 12 | @Override 13 | public void serialize(CustomEventUser eventUser, JsonGenerator jgen, SerializerProvider provider) throws IOException { 14 | jgen.writeStartObject(); 15 | 16 | if (eventUser.getChannel().isPresent()) { 17 | jgen.writeStringField(eventUser.getChannelType().get().getIdentifier(), eventUser.getChannel().get()); 18 | } 19 | if (eventUser.getNamedUserId().isPresent()) { 20 | jgen.writeStringField("named_user_id", eventUser.getNamedUserId().get()); 21 | } 22 | jgen.writeEndObject(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/experiments/model/ExperimentModelObject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2017. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.experiments.model; 6 | 7 | import com.urbanairship.api.common.model.APIModelObject; 8 | import com.urbanairship.api.experiments.parse.ExperimentObjectMapper; 9 | 10 | public class ExperimentModelObject extends APIModelObject { 11 | @Override 12 | public String toJSON() { 13 | try { 14 | return ExperimentObjectMapper.getInstance().writeValueAsString(this); 15 | } catch ( Exception e ) { 16 | return toJSON(e); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/experiments/parse/VariantPushPayloadSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2017. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.experiments.parse; 6 | 7 | import com.fasterxml.jackson.core.JsonGenerator; 8 | import com.fasterxml.jackson.databind.JsonSerializer; 9 | import com.fasterxml.jackson.databind.SerializerProvider; 10 | import com.urbanairship.api.experiments.model.VariantPushPayload; 11 | 12 | import java.io.IOException; 13 | 14 | public class VariantPushPayloadSerializer extends JsonSerializer { 15 | 16 | @Override 17 | public void serialize(VariantPushPayload value, JsonGenerator jgen, SerializerProvider provider) throws IOException { 18 | jgen.writeStartObject(); 19 | 20 | if (value.getNotification().isPresent()) { 21 | jgen.writeObjectField("notification", value.getNotification().get()); 22 | } 23 | if (value.getPushOptions().isPresent()) { 24 | jgen.writeObjectField("options", value.getPushOptions().get()); 25 | } 26 | if (value.getInApp().isPresent()) { 27 | jgen.writeObjectField("in_app", value.getInApp().get()); 28 | } 29 | 30 | jgen.writeEndObject(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/inbox/model/MessageIdError.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.inbox.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | 5 | public class MessageIdError { 6 | private final String messageId; 7 | private final String errorMessage; 8 | private final Integer errorCode; 9 | 10 | public MessageIdError(@JsonProperty("message_id") String messageId, 11 | @JsonProperty("error_message") String errorMessage, 12 | @JsonProperty("error_code") Integer errorCode) { 13 | this.messageId = messageId; 14 | this.errorMessage = errorMessage; 15 | this.errorCode = errorCode; 16 | } 17 | 18 | /** 19 | * Get the message id. 20 | * 21 | * @return String messageId 22 | */ 23 | public String getMessageId() { 24 | return messageId; 25 | } 26 | 27 | /** 28 | * Get the error message. 29 | * 30 | * @return String errorMessage 31 | */ 32 | public String getErrorMessage() { 33 | return errorMessage; 34 | } 35 | 36 | /** 37 | * Get the value for the error code. 38 | * 39 | * @return Integer errorCode 40 | */ 41 | public Integer getErrorCode() { 42 | return errorCode; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/nameduser/model/NamedUserModelObject.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.nameduser.model; 2 | 3 | import com.fasterxml.jackson.databind.ObjectMapper; 4 | import com.urbanairship.api.common.model.APIModelObject; 5 | import com.urbanairship.api.nameduser.parse.NamedUserObjectMapper; 6 | 7 | public class NamedUserModelObject extends APIModelObject { 8 | private final ObjectMapper MAPPER = NamedUserObjectMapper.getInstance(); 9 | 10 | @Override 11 | public String toJSON() { 12 | try { 13 | return MAPPER.writeValueAsString(this); 14 | } catch (Exception e) { 15 | return toJSON(e); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/nameduser/model/NamedUserScopeType.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.nameduser.model; 2 | 3 | import java.util.Arrays; 4 | import java.util.Optional; 5 | 6 | public enum NamedUserScopeType { 7 | 8 | APP("app"), 9 | WEB("web"), 10 | EMAIL("email"), 11 | SMS("sms"); 12 | 13 | private final String identifier; 14 | 15 | private NamedUserScopeType(String identifier) { 16 | this.identifier = identifier; 17 | } 18 | 19 | public String getIdentifier() { 20 | return identifier; 21 | } 22 | 23 | public static Optional find (String identifier) { 24 | for (NamedUserScopeType scopeType : values()) { 25 | if (scopeType.getIdentifier().equals(identifier)) { 26 | return Optional.of(scopeType); 27 | } 28 | } 29 | return Arrays.stream(values()) 30 | .filter(scopeType -> scopeType.getIdentifier().equals(identifier)) 31 | .findFirst(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/nameduser/model/NamedUserUpdateChannelAction.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.nameduser.model; 2 | 3 | import java.util.Optional; 4 | 5 | public enum NamedUserUpdateChannelAction { 6 | ASSOCIATE("associate"), 7 | DISASSOCIATE("disassociate"); 8 | 9 | private final String identifier; 10 | 11 | private NamedUserUpdateChannelAction(String identifier) { 12 | this.identifier = identifier; 13 | } 14 | 15 | public static Optional find(String identifier) { 16 | for (NamedUserUpdateChannelAction namedUserUpdateChannelAction : values()) { 17 | if (namedUserUpdateChannelAction.getIdentifier().equals(identifier)) { 18 | return Optional.of(namedUserUpdateChannelAction); 19 | } 20 | } 21 | 22 | return Optional.empty(); 23 | } 24 | 25 | public String getIdentifier() { 26 | return identifier; 27 | } 28 | } -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/nameduser/model/NamedUserUpdateDeviceType.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.nameduser.model; 2 | 3 | import java.util.Optional; 4 | 5 | public enum NamedUserUpdateDeviceType { 6 | 7 | IOS_CHANNEL("ios"), 8 | ANDROID_CHANNEL("android"), 9 | AMAZON_CHANNEL("amazon"), 10 | WEB_CHANNEL("web"), 11 | SMS("sms"), 12 | EMAIL_ADDRESS("email_address"), 13 | OPEN("open"); 14 | 15 | private final String identifier; 16 | 17 | private NamedUserUpdateDeviceType(String identifier) { 18 | this.identifier = identifier; 19 | } 20 | 21 | public static Optional find (String identifier) { 22 | for (NamedUserUpdateDeviceType audienceType : values()) { 23 | if (audienceType.getIdentifier().equals(identifier)) { 24 | return Optional.ofNullable(audienceType); 25 | } 26 | } 27 | 28 | return Optional.empty(); 29 | } 30 | 31 | public String getIdentifier() { 32 | return identifier; 33 | } 34 | } -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/nameduser/parse/NamedUserAttributePayloadSerializer.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.nameduser.parse; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.databind.JsonSerializer; 5 | import com.fasterxml.jackson.databind.SerializerProvider; 6 | import com.urbanairship.api.channel.model.attributes.Attribute; 7 | import com.urbanairship.api.nameduser.model.NamedUserAttributePayload; 8 | 9 | import java.io.IOException; 10 | 11 | public class NamedUserAttributePayloadSerializer extends JsonSerializer { 12 | @Override 13 | public void serialize(NamedUserAttributePayload payload, JsonGenerator jgen, SerializerProvider provider) throws IOException { 14 | jgen.writeStartObject(); 15 | 16 | jgen.writeArrayFieldStart("attributes"); 17 | 18 | for (Attribute attribute : payload.getAttributes()) { 19 | jgen.writeObject(attribute); 20 | } 21 | 22 | jgen.writeEndArray(); 23 | 24 | jgen.writeEndObject(); 25 | 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/nameduser/parse/NamedUserScopedPayloadSerializer.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.nameduser.parse; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.databind.JsonSerializer; 5 | import com.fasterxml.jackson.databind.SerializerProvider; 6 | import com.urbanairship.api.nameduser.model.NamedUserScopedPayload; 7 | import com.urbanairship.api.nameduser.model.NamedUserScope; 8 | 9 | import java.io.IOException; 10 | 11 | public class NamedUserScopedPayloadSerializer extends JsonSerializer { 12 | @Override 13 | public void serialize(NamedUserScopedPayload payload, JsonGenerator jgen, SerializerProvider provider) throws IOException { 14 | jgen.writeStartObject(); 15 | 16 | jgen.writeArrayFieldStart("scoped"); 17 | 18 | for (NamedUserScope namedUserScope : payload.getScoped()) { 19 | jgen.writeObject(namedUserScope); 20 | } 21 | 22 | jgen.writeEndArray(); 23 | 24 | jgen.writeEndObject(); 25 | 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/nameduser/parse/NamedUserUpdateChannelSerializer.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.nameduser.parse; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.databind.JsonSerializer; 5 | import com.fasterxml.jackson.databind.SerializerProvider; 6 | import com.urbanairship.api.channel.Constants; 7 | import com.urbanairship.api.nameduser.model.NamedUserUpdateChannel; 8 | 9 | import java.io.IOException; 10 | 11 | public class NamedUserUpdateChannelSerializer extends JsonSerializer { 12 | 13 | @Override 14 | public void serialize(NamedUserUpdateChannel channel, JsonGenerator jgen, SerializerProvider provider) throws IOException { 15 | jgen.writeStartObject(); 16 | 17 | if (channel.getChannelId().isPresent()) { 18 | jgen.writeStringField(Constants.CHANNEL_ID, channel.getChannelId().get()); 19 | } 20 | 21 | if (channel.getDeviceType().isPresent()) { 22 | jgen.writeStringField(Constants.DEVICE_TYPE, channel.getDeviceType().get().getIdentifier()); 23 | } 24 | 25 | if (channel.getEmailAddress().isPresent()) { 26 | jgen.writeStringField(Constants.EMAIL_ADDRESS, channel.getEmailAddress().get()); 27 | } 28 | 29 | jgen.writeEndObject(); 30 | } 31 | } -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/model/OrchestrationType.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.push.model; 2 | 3 | import java.util.Optional; 4 | 5 | /** 6 | * Enum for specifying the orchestration type. 7 | */ 8 | public enum OrchestrationType { 9 | CHANNEL_PRIORITY("channel_priority"), 10 | TRIGGERING_CHANNEL("triggering_channel"), 11 | LAST_ACTIVE("last_active"), 12 | FAN_OUT("fan_out"); 13 | 14 | private final String orchestrationType; 15 | 16 | OrchestrationType(String orchestrationType) { 17 | this.orchestrationType = orchestrationType; 18 | } 19 | 20 | public static Optional find(String orchestrationType) { 21 | for (OrchestrationType type : values()) { 22 | if (type.orchestrationType.equals(orchestrationType)) { 23 | return Optional.of(type); 24 | } 25 | } 26 | 27 | return Optional.empty(); 28 | } 29 | 30 | public String getOrchestrationType() { 31 | return orchestrationType; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/model/Position.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.push.model; 6 | 7 | import java.util.Optional; 8 | 9 | /** 10 | * Enum for specifying the notification position. 11 | */ 12 | public enum Position { 13 | TOP("top"), 14 | BOTTOM("bottom"); 15 | 16 | private final String type; 17 | 18 | private Position(String type) { 19 | this.type = type; 20 | } 21 | 22 | public static Optional find(String type) { 23 | for (Position position : values()) { 24 | if (position.getType().equals(type)) { 25 | return Optional.of(position); 26 | } 27 | } 28 | 29 | return Optional.empty(); 30 | } 31 | 32 | public String getType() { 33 | return type; 34 | } 35 | } -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/model/PushModelObject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.push.model; 6 | 7 | import com.urbanairship.api.common.model.APIModelObject; 8 | import com.urbanairship.api.push.parse.PushObjectMapper; 9 | 10 | public class PushModelObject extends APIModelObject { 11 | @Override 12 | public String toJSON() { 13 | try { 14 | return PushObjectMapper.getInstance().writeValueAsString(this); 15 | } catch ( Exception e ) { 16 | return toJSON(e); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/model/audience/CompoundSelector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.push.model.audience; 6 | 7 | /** 8 | * Selector expressions that have an array of one or more selector 9 | * expressions as children. 10 | */ 11 | public interface CompoundSelector extends Selector { 12 | Iterable getChildren(); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/model/audience/Selector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.push.model.audience; 6 | 7 | import com.urbanairship.api.push.model.DeviceTypeData; 8 | 9 | /** 10 | * The root of all selector expressions. 11 | */ 12 | public interface Selector { 13 | SelectorType getType(); 14 | DeviceTypeData getApplicableDeviceTypes(); 15 | void accept(SelectorVisitor visitor); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/model/audience/SelectorCategory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.push.model.audience; 6 | 7 | public enum SelectorCategory { 8 | ATOMIC, 9 | VALUE, 10 | COMPOUND, 11 | LOCATION, 12 | SMS 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/model/audience/SelectorVisitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.push.model.audience; 6 | 7 | public interface SelectorVisitor { 8 | void enter(Selector s); 9 | void exit(Selector s); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/model/audience/ValueSelector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.push.model.audience; 6 | 7 | import java.util.Map; 8 | import java.util.Optional; 9 | 10 | /** 11 | * A selector which has a single value associated with it. Most atomic 12 | * selector expressions fall into this category, e.g. { "tag" : 13 | * "san_francisco_giants" }. 14 | */ 15 | public interface ValueSelector extends Selector { 16 | String getValue(); 17 | Optional> getAttributes(); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/model/audience/createandsend/OpenChannel.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.push.model.audience.createandsend; 2 | 3 | public class OpenChannel { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/model/audience/location/DateRange.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.push.model.audience.location; 6 | 7 | import org.joda.time.DateTime; 8 | 9 | public interface DateRange { 10 | DateTime getStart(); 11 | DateTime getEnd(); 12 | DateRangeUnit getResolution(); 13 | PresenceTimeframe getTimeframe(); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/model/audience/location/PresenceTimeframe.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.push.model.audience.location; 6 | 7 | public enum PresenceTimeframe { 8 | LAST_SEEN, 9 | ANYTIME 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/model/notification/DevicePayloadOverride.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.push.model.notification; 6 | 7 | import com.urbanairship.api.push.model.DeviceType; 8 | 9 | public interface DevicePayloadOverride { 10 | DeviceType getDeviceType(); 11 | Object getAlert(); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/model/notification/actions/Action.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.push.model.notification.actions; 6 | 7 | /** 8 | * Notification actions. 9 | * @param Action type 10 | */ 11 | public interface Action { 12 | /** 13 | * Content/parameters for the action. 14 | * @return A 15 | */ 16 | A getValue(); 17 | 18 | /** 19 | * The specific type of action. 20 | * @return ActionType 21 | */ 22 | ActionType getActionType(); 23 | 24 | /** 25 | * A marker interface to distinguish "open" actions from vanilla 26 | * actions. 27 | * @param OpenAction type 28 | */ 29 | interface OpenAction extends Action { } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/model/notification/actions/ActionType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.push.model.notification.actions; 6 | 7 | public enum ActionType { 8 | ADD_TAG, 9 | REMOVE_TAG, 10 | OPEN_LANDING_PAGE_WITH_CONTENT, 11 | OPEN_DEEP_LINK, 12 | OPEN_EXTERNAL_URL, 13 | APP_DEFINED, 14 | SHARE 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/model/notification/android/AndroidLiveUpdateEvent.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.push.model.notification.android; 2 | 3 | import java.util.Optional; 4 | 5 | /** 6 | * Enum of iosLiveActivityEvent 7 | */ 8 | public enum AndroidLiveUpdateEvent { 9 | 10 | START("start"), 11 | UPDATE("update"), 12 | END("end"); 13 | 14 | private final String androidLiveUpdateEvent; 15 | 16 | AndroidLiveUpdateEvent(String androidLiveUpdateEvent) { 17 | this.androidLiveUpdateEvent = androidLiveUpdateEvent; 18 | } 19 | 20 | public String getAndroidLiveUpdateEvent() { 21 | return androidLiveUpdateEvent; 22 | } 23 | 24 | public static Optional find(String identifier) { 25 | for (AndroidLiveUpdateEvent androidLiveUpdateEvent : values()) { 26 | if (androidLiveUpdateEvent.getAndroidLiveUpdateEvent().equals(identifier)) { 27 | return Optional.of(androidLiveUpdateEvent); 28 | } 29 | } 30 | 31 | return Optional.empty(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/model/notification/android/Category.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.push.model.notification.android; 6 | 7 | import java.util.Optional; 8 | 9 | /** 10 | * Enum of Android categories 11 | */ 12 | public enum Category { 13 | 14 | ALARM("alarm"), 15 | CALL("call"), 16 | EMAIL("email"), 17 | ERR("err"), 18 | EVENT("event"), 19 | MSG("msg"), 20 | PROMO("promo"), 21 | RECOMMENDATION("recommendation"), 22 | SERVICE("service"), 23 | SOCIAL("social"), 24 | STATUS("status"), 25 | SYS("sys"), 26 | TRANSPORT("transport"); 27 | 28 | private final String category; 29 | 30 | private Category(String category) { 31 | this.category = category; 32 | } 33 | 34 | public String getCategory() { 35 | return category; 36 | } 37 | 38 | public static Optional find(String identifier) { 39 | for (Category channelType : values()) { 40 | if (channelType.getCategory().equals(identifier)) { 41 | return Optional.of(channelType); 42 | } 43 | } 44 | 45 | return Optional.empty(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/model/notification/email/MessageType.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.push.model.notification.email; 2 | 3 | import java.util.Optional; 4 | 5 | /** 6 | * Enum of Message Types categories 7 | */ 8 | public enum MessageType { 9 | 10 | COMMERCIAL("commercial"), 11 | TRANSACTIONAL("transactional"); 12 | 13 | private final String messageType; 14 | 15 | private MessageType(String messageType) { 16 | this.messageType = messageType; 17 | } 18 | 19 | /** 20 | * Gets the message type 21 | * 22 | * @return String messageType 23 | * */ 24 | public String getMessageType() { 25 | return messageType; 26 | } 27 | 28 | public static Optional find(String identifier) { 29 | for (MessageType messageType : values()) { 30 | if (messageType.getMessageType().equals(identifier)) { 31 | return Optional.of(messageType); 32 | } 33 | } 34 | 35 | return Optional.empty(); 36 | } 37 | } -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/model/notification/ios/IOSInterruptionLevel.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.push.model.notification.ios; 2 | 3 | import java.util.Optional; 4 | 5 | /** 6 | * Enum of iOS Interruption levels 7 | */ 8 | public enum IOSInterruptionLevel { 9 | 10 | PASSIVE("passive"), 11 | ACTIVE("active"), 12 | TIME_SENSITIVE("time-sensitive"), 13 | CRITICAL("critical"); 14 | 15 | private final String interruptionLevel; 16 | 17 | private IOSInterruptionLevel(String interruptionLevel) { 18 | this.interruptionLevel = interruptionLevel; 19 | } 20 | 21 | public String getInterruptionLevel() { 22 | return interruptionLevel; 23 | } 24 | 25 | public static Optional find(String identifier) { 26 | for (IOSInterruptionLevel interruptionLevel : values()) { 27 | if (interruptionLevel.getInterruptionLevel().equals(identifier)) { 28 | return Optional.of(interruptionLevel); 29 | } 30 | } 31 | 32 | return Optional.empty(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/model/notification/ios/IOSLiveActivityEvent.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.push.model.notification.ios; 2 | 3 | import java.util.Optional; 4 | 5 | /** 6 | * Enum of iosLiveActivityEvent 7 | */ 8 | public enum IOSLiveActivityEvent { 9 | 10 | START("start"), 11 | UPDATE("update"), 12 | END("end"); 13 | 14 | private final String iosLiveActivityEvent; 15 | 16 | IOSLiveActivityEvent(String iosLiveActivityEvent) { 17 | this.iosLiveActivityEvent = iosLiveActivityEvent; 18 | } 19 | 20 | public String getIosLiveActivityEvent() { 21 | return iosLiveActivityEvent; 22 | } 23 | 24 | public static Optional find(String identifier) { 25 | for (IOSLiveActivityEvent iosLiveActivityEvent : values()) { 26 | if (iosLiveActivityEvent.getIosLiveActivityEvent().equals(identifier)) { 27 | return Optional.of(iosLiveActivityEvent); 28 | } 29 | } 30 | 31 | return Optional.empty(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/model/notification/web/WebImage.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.push.model.notification.web; 2 | 3 | import com.google.common.base.Objects; 4 | import com.google.common.base.Preconditions; 5 | 6 | public class WebImage { 7 | private final String url; 8 | 9 | public WebImage(String url) { 10 | Preconditions.checkNotNull(url, "Url cannot be null."); 11 | this.url = url; 12 | } 13 | 14 | private WebImage(Builder builder) { 15 | this.url = builder.url; 16 | } 17 | 18 | public static Builder newBuilder() { 19 | return new Builder(); 20 | } 21 | 22 | public String getUrl() { 23 | return url; 24 | } 25 | 26 | @Override 27 | public boolean equals(Object o) { 28 | if (this == o) return true; 29 | if (o == null || getClass() != o.getClass()) return false; 30 | WebImage webImage = (WebImage) o; 31 | return Objects.equal(url, webImage.url); 32 | } 33 | 34 | @Override 35 | public int hashCode() { 36 | return Objects.hashCode(url); 37 | } 38 | 39 | public static class Builder { 40 | String url = null; 41 | 42 | public Builder setUrl(String url) { 43 | this.url = url; 44 | return this; 45 | } 46 | 47 | public WebImage build() { 48 | return new WebImage(this); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/CampaignsSerializer.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.push.parse; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.databind.JsonSerializer; 5 | import com.fasterxml.jackson.databind.SerializerProvider; 6 | import com.urbanairship.api.push.model.Campaigns; 7 | 8 | import java.io.IOException; 9 | 10 | public class CampaignsSerializer extends JsonSerializer { 11 | @Override 12 | public void serialize(Campaigns campaigns, JsonGenerator jsonGenerator, SerializerProvider provider) throws IOException{ 13 | jsonGenerator.writeStartObject(); 14 | 15 | jsonGenerator.writeObjectField("categories", campaigns.getCategories()); 16 | 17 | jsonGenerator.writeEndObject(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/DeviceTypeDataSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.push.parse; 6 | 7 | import com.fasterxml.jackson.core.JsonGenerator; 8 | import com.fasterxml.jackson.databind.JsonSerializer; 9 | import com.fasterxml.jackson.databind.SerializerProvider; 10 | import com.urbanairship.api.push.model.DeviceTypeData; 11 | 12 | import java.io.IOException; 13 | 14 | public class DeviceTypeDataSerializer extends JsonSerializer { 15 | 16 | @Override 17 | public void serialize(DeviceTypeData payload, JsonGenerator jgen, SerializerProvider provider) throws IOException { 18 | jgen.writeObject(payload.getDeviceTypes().get()); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/DeviceTypeSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.push.parse; 6 | 7 | import com.fasterxml.jackson.core.JsonGenerator; 8 | import com.fasterxml.jackson.databind.JsonSerializer; 9 | import com.fasterxml.jackson.databind.SerializerProvider; 10 | import com.urbanairship.api.push.model.DeviceType; 11 | 12 | import java.io.IOException; 13 | 14 | public class DeviceTypeSerializer extends JsonSerializer { 15 | 16 | @Override 17 | public void serialize(DeviceType deviceType, JsonGenerator jgen, SerializerProvider provider) throws IOException { 18 | jgen.writeString(deviceType.getIdentifier()); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/DisplaySerializer.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.push.parse; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.databind.JsonSerializer; 5 | import com.fasterxml.jackson.databind.SerializerProvider; 6 | import com.urbanairship.api.push.model.Display; 7 | 8 | import java.io.IOException; 9 | 10 | public class DisplaySerializer extends JsonSerializer { 11 | 12 | @Override 13 | public void serialize(Display display, JsonGenerator jsonGenerator, SerializerProvider provider) throws IOException { 14 | jsonGenerator.writeStartObject(); 15 | 16 | if (display.getPrimaryColor().isPresent()) { 17 | jsonGenerator.writeStringField("primary_color", display.getPrimaryColor().get()); 18 | } 19 | 20 | if (display.getSecondaryColor().isPresent()) { 21 | jsonGenerator.writeStringField("secondary_color", display.getSecondaryColor().get()); 22 | } 23 | 24 | if (display.getDuration().isPresent()) { 25 | jsonGenerator.writeNumberField("duration", display.getDuration().get()); 26 | } 27 | 28 | if (display.getPosition().isPresent()) { 29 | jsonGenerator.writeStringField("position", display.getPosition().get().getType()); 30 | } 31 | 32 | jsonGenerator.writeEndObject(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/OrchestrationReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.push.parse; 6 | 7 | import com.fasterxml.jackson.core.JsonParser; 8 | import com.fasterxml.jackson.core.type.TypeReference; 9 | import com.urbanairship.api.common.parse.JsonObjectReader; 10 | import com.urbanairship.api.push.model.Orchestration; 11 | import com.urbanairship.api.push.model.OrchestrationType; 12 | 13 | import java.io.IOException; 14 | import java.util.List; 15 | 16 | public class OrchestrationReader implements JsonObjectReader { 17 | 18 | private final Orchestration.Builder builder; 19 | 20 | public OrchestrationReader() { 21 | this.builder = Orchestration.newBuilder(); 22 | } 23 | 24 | public void readOrchestrationType(JsonParser parser) throws IOException { 25 | builder.setOrchestrationType(parser.readValueAs(OrchestrationType.class)); 26 | } 27 | 28 | public void readOrchestrationChannelPriority(JsonParser parser) throws IOException { 29 | builder.addAllOrchestrationChannelPriority(parser.readValueAs(new TypeReference>() { 30 | })); 31 | } 32 | 33 | @Override 34 | public Orchestration validateAndBuild() throws IOException { 35 | return builder.build(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/OrchestrationSerializer.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.push.parse; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.databind.JsonSerializer; 5 | import com.fasterxml.jackson.databind.SerializerProvider; 6 | import com.urbanairship.api.push.model.Orchestration; 7 | 8 | import java.io.IOException; 9 | 10 | public class OrchestrationSerializer extends JsonSerializer { 11 | @Override 12 | public void serialize(Orchestration orchestration, JsonGenerator jgen, SerializerProvider provider) throws IOException { 13 | jgen.writeStartObject(); 14 | 15 | jgen.writeStringField("type", orchestration.getOrchestrationType().getOrchestrationType()); 16 | 17 | if (!orchestration.getOrchestrationChannelPriority().isEmpty()) { 18 | jgen.writeObjectField("channel_priority", orchestration.getOrchestrationChannelPriority()); 19 | } 20 | 21 | jgen.writeEndObject(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/PlatformDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.push.parse; 6 | 7 | import com.fasterxml.jackson.core.JsonParser; 8 | import com.fasterxml.jackson.databind.DeserializationContext; 9 | import com.fasterxml.jackson.databind.JsonDeserializer; 10 | import com.urbanairship.api.common.parse.APIParsingException; 11 | import com.urbanairship.api.push.model.DeviceType; 12 | 13 | import java.io.IOException; 14 | import java.util.Optional; 15 | 16 | public class PlatformDeserializer extends JsonDeserializer { 17 | 18 | @Override 19 | public DeviceType deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { 20 | String deviceTypeString = jp.getText(); 21 | Optional platform = DeviceType.find(deviceTypeString); 22 | if (!platform.isPresent()) { 23 | APIParsingException.raise(String.format("Unrecognized device type '%s'", deviceTypeString), jp); 24 | } 25 | return platform.get(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/PushExpirySerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.push.parse; 6 | 7 | import com.fasterxml.jackson.core.JsonGenerator; 8 | import com.fasterxml.jackson.databind.JsonSerializer; 9 | import com.fasterxml.jackson.databind.SerializerProvider; 10 | import com.urbanairship.api.common.parse.DateFormats; 11 | import com.urbanairship.api.push.model.PushExpiry; 12 | 13 | import java.io.IOException; 14 | 15 | public class PushExpirySerializer extends JsonSerializer { 16 | 17 | @Override 18 | public void serialize(PushExpiry payload, JsonGenerator jgen, SerializerProvider provider) throws IOException { 19 | if (payload.getExpiryTimeStamp().isPresent()) { 20 | jgen.writeString(DateFormats.DATE_FORMATTER.print(payload.getExpiryTimeStamp().get())); 21 | } 22 | if (payload.getExpirySeconds().isPresent()) { 23 | jgen.writeNumber(payload.getExpirySeconds().get()); 24 | } 25 | if (payload.getExpiryPersonalization().isPresent()) { 26 | jgen.writeString(payload.getExpiryPersonalization().get()); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/audience/location/AbsoluteDateRangeSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.push.parse.audience.location; 6 | 7 | import com.fasterxml.jackson.core.JsonGenerator; 8 | import com.fasterxml.jackson.databind.JsonSerializer; 9 | import com.fasterxml.jackson.databind.SerializerProvider; 10 | import com.urbanairship.api.push.model.audience.location.AbsoluteDateRange; 11 | import com.urbanairship.api.push.model.audience.location.PresenceTimeframe; 12 | 13 | import java.io.IOException; 14 | 15 | public class AbsoluteDateRangeSerializer extends JsonSerializer { 16 | @Override 17 | public void serialize(AbsoluteDateRange range, JsonGenerator jgen, SerializerProvider provider) throws IOException { 18 | jgen.writeStartObject(); 19 | if (range.getTimeframe() == PresenceTimeframe.LAST_SEEN) { 20 | jgen.writeBooleanField("last_seen", true); 21 | } 22 | jgen.writeObjectFieldStart(range.getResolution().getIdentifier()); 23 | jgen.writeObjectField("start", range.getStart()); 24 | jgen.writeObjectField("end", range.getEnd()); 25 | jgen.writeEndObject(); 26 | jgen.writeEndObject(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/audience/location/RecentDateRangeSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.push.parse.audience.location; 6 | 7 | import com.fasterxml.jackson.core.JsonGenerator; 8 | import com.fasterxml.jackson.databind.JsonSerializer; 9 | import com.fasterxml.jackson.databind.SerializerProvider; 10 | import com.urbanairship.api.push.model.audience.location.PresenceTimeframe; 11 | import com.urbanairship.api.push.model.audience.location.RecentDateRange; 12 | 13 | import java.io.IOException; 14 | 15 | public class RecentDateRangeSerializer extends JsonSerializer { 16 | @Override 17 | public void serialize(RecentDateRange range, JsonGenerator jgen, SerializerProvider provider) throws IOException { 18 | jgen.writeStartObject(); 19 | if (range.getTimeframe() == PresenceTimeframe.LAST_SEEN) { 20 | jgen.writeBooleanField("last_seen", true); 21 | } 22 | jgen.writeObjectFieldStart("recent"); 23 | jgen.writeNumberField(range.getResolution().getIdentifier(), 24 | range.getUnits()); 25 | jgen.writeEndObject(); 26 | jgen.writeEndObject(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/audience/location/SegmentDefinitionReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.push.parse.audience.location; 6 | 7 | import com.fasterxml.jackson.core.JsonParser; 8 | import com.urbanairship.api.common.parse.JsonObjectReader; 9 | import com.urbanairship.api.common.parse.StringFieldDeserializer; 10 | import com.urbanairship.api.push.model.audience.Selector; 11 | import com.urbanairship.api.push.model.audience.location.SegmentDefinition; 12 | 13 | import java.io.IOException; 14 | 15 | public class SegmentDefinitionReader implements JsonObjectReader { 16 | 17 | private final SegmentDefinition.Builder builder; 18 | 19 | public SegmentDefinitionReader() { 20 | this.builder = SegmentDefinition.newBuilder(); 21 | } 22 | 23 | public void readDisplayName(JsonParser parser) throws IOException { 24 | builder.setDisplayName(StringFieldDeserializer.INSTANCE.deserialize(parser, "display_name")); 25 | } 26 | 27 | public void readCriteria(JsonParser parser) throws IOException { 28 | builder.setCriteria(parser.readValueAs(Selector.class)); 29 | } 30 | 31 | @Override 32 | public SegmentDefinition validateAndBuild() throws IOException { 33 | return builder.build(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/audience/sms/SmsSelectorSerializer.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.push.parse.audience.sms; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.databind.JsonSerializer; 5 | import com.fasterxml.jackson.databind.SerializerProvider; 6 | import com.urbanairship.api.push.model.audience.sms.SmsSelector; 7 | 8 | import java.io.IOException; 9 | 10 | public class SmsSelectorSerializer extends JsonSerializer { 11 | 12 | @Override 13 | public void serialize(SmsSelector selector, JsonGenerator jgen, SerializerProvider provider) throws IOException { 14 | jgen.writeStartObject(); 15 | jgen.writeObjectFieldStart("sms_id"); 16 | jgen.writeStringField("msisdn", selector.getMsisdn()); 17 | jgen.writeStringField("sender", selector.getSender()); 18 | jgen.writeEndObject(); 19 | jgen.writeEndObject(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/notification/InteractiveSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.push.parse.notification; 6 | 7 | import com.fasterxml.jackson.core.JsonGenerator; 8 | import com.fasterxml.jackson.databind.JsonSerializer; 9 | import com.fasterxml.jackson.databind.SerializerProvider; 10 | import com.urbanairship.api.push.model.notification.Interactive; 11 | import com.urbanairship.api.push.model.notification.actions.Actions; 12 | 13 | import java.io.IOException; 14 | 15 | public class InteractiveSerializer extends JsonSerializer { 16 | @Override 17 | public void serialize(Interactive value, JsonGenerator jgen, SerializerProvider provider) throws IOException { 18 | jgen.writeStartObject(); 19 | jgen.writeStringField("type", value.getType()); 20 | if (value.getButtonActions().size() > 0) { 21 | jgen.writeObjectFieldStart("button_actions"); 22 | for (String buttonID : value.getButtonActions().keySet()) { 23 | Actions actions = value.getButtonActions().get(buttonID); 24 | jgen.writeObjectField(buttonID, actions); 25 | } 26 | jgen.writeEndObject(); 27 | } 28 | jgen.writeEndObject(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/notification/actions/AddTagActionSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.push.parse.notification.actions; 6 | 7 | import com.fasterxml.jackson.core.JsonGenerator; 8 | import com.fasterxml.jackson.databind.JsonSerializer; 9 | import com.fasterxml.jackson.databind.ObjectMapper; 10 | import com.fasterxml.jackson.databind.SerializerProvider; 11 | import com.urbanairship.api.push.model.notification.actions.AddTagAction; 12 | import com.urbanairship.api.push.parse.PushObjectMapper; 13 | 14 | import java.io.IOException; 15 | 16 | public final class AddTagActionSerializer extends JsonSerializer { 17 | private static final ObjectMapper MAPPER = PushObjectMapper.getInstance(); 18 | 19 | @Override 20 | public void serialize(AddTagAction tagAction, JsonGenerator jgen, SerializerProvider provider) throws IOException { 21 | jgen.writeTree(MAPPER.valueToTree(tagAction.getValue())); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/notification/actions/AppDefinedSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.push.parse.notification.actions; 6 | 7 | import com.fasterxml.jackson.core.JsonGenerator; 8 | import com.fasterxml.jackson.databind.JsonSerializer; 9 | import com.fasterxml.jackson.databind.SerializerProvider; 10 | import com.urbanairship.api.push.model.notification.actions.AppDefinedAction; 11 | 12 | import java.io.IOException; 13 | 14 | public class AppDefinedSerializer extends JsonSerializer { 15 | @Override 16 | public void serialize(AppDefinedAction value, JsonGenerator jgen, SerializerProvider provider) throws IOException { 17 | jgen.writeTree(value.getValue()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/notification/actions/DeepLinkSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.push.parse.notification.actions; 6 | 7 | import com.fasterxml.jackson.core.JsonGenerator; 8 | import com.fasterxml.jackson.databind.JsonSerializer; 9 | import com.fasterxml.jackson.databind.SerializerProvider; 10 | import com.urbanairship.api.push.model.notification.actions.DeepLinkAction; 11 | 12 | import java.io.IOException; 13 | 14 | public final class DeepLinkSerializer extends JsonSerializer { 15 | @Override 16 | public void serialize(DeepLinkAction value, JsonGenerator jgen, SerializerProvider provider) throws IOException { 17 | jgen.writeStartObject(); 18 | try { 19 | jgen.writeObjectField("type", "deep_link"); 20 | jgen.writeObjectField("content", value.getLink()); 21 | 22 | if (value.getFallbackUrl().isPresent()) { 23 | jgen.writeStringField("fallback_url", value.getFallbackUrl().get()); 24 | } 25 | } 26 | finally { 27 | jgen.writeEndObject(); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/notification/actions/ExternalURLSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.push.parse.notification.actions; 6 | 7 | import com.fasterxml.jackson.core.JsonGenerator; 8 | import com.fasterxml.jackson.databind.JsonSerializer; 9 | import com.fasterxml.jackson.databind.SerializerProvider; 10 | import com.urbanairship.api.push.model.notification.actions.OpenExternalURLAction; 11 | 12 | import java.io.IOException; 13 | 14 | public final class ExternalURLSerializer extends JsonSerializer { 15 | @Override 16 | public void serialize(OpenExternalURLAction value, JsonGenerator jgen, SerializerProvider provider) throws IOException { 17 | jgen.writeStartObject(); 18 | try { 19 | jgen.writeObjectField("type", "url"); 20 | jgen.writeObjectField("content", value.getValue().toString()); 21 | } 22 | finally { 23 | jgen.writeEndObject(); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/notification/actions/RemoveTagActionSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.push.parse.notification.actions; 6 | 7 | import com.fasterxml.jackson.core.JsonGenerator; 8 | import com.fasterxml.jackson.databind.JsonSerializer; 9 | import com.fasterxml.jackson.databind.ObjectMapper; 10 | import com.fasterxml.jackson.databind.SerializerProvider; 11 | import com.urbanairship.api.push.model.notification.actions.RemoveTagAction; 12 | import com.urbanairship.api.push.parse.PushObjectMapper; 13 | 14 | import java.io.IOException; 15 | 16 | public final class RemoveTagActionSerializer extends JsonSerializer { 17 | private static final ObjectMapper MAPPER = PushObjectMapper.getInstance(); 18 | 19 | @Override 20 | public void serialize(RemoveTagAction tagAction, JsonGenerator jgen, SerializerProvider provider) throws IOException { 21 | jgen.writeTree(MAPPER.valueToTree(tagAction.getValue())); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/notification/actions/ShareActionDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.push.parse.notification.actions; 6 | 7 | import com.fasterxml.jackson.core.JsonParser; 8 | import com.fasterxml.jackson.databind.DeserializationContext; 9 | import com.fasterxml.jackson.databind.JsonDeserializer; 10 | import com.urbanairship.api.common.parse.StringFieldDeserializer; 11 | import com.urbanairship.api.push.model.notification.actions.ShareAction; 12 | 13 | import java.io.IOException; 14 | 15 | public class ShareActionDeserializer extends JsonDeserializer { 16 | @Override 17 | public ShareAction deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { 18 | return new ShareAction(StringFieldDeserializer.INSTANCE.deserialize(jp, "share")); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/notification/actions/ShareActionSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.push.parse.notification.actions; 6 | 7 | import com.fasterxml.jackson.core.JsonGenerator; 8 | import com.fasterxml.jackson.databind.JsonSerializer; 9 | import com.fasterxml.jackson.databind.SerializerProvider; 10 | import com.urbanairship.api.push.model.notification.actions.ShareAction; 11 | 12 | import java.io.IOException; 13 | 14 | public final class ShareActionSerializer extends JsonSerializer { 15 | @Override 16 | public void serialize(ShareAction value, JsonGenerator jgen, SerializerProvider provider) throws IOException { 17 | jgen.writeString(value.getValue()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/notification/actions/TagActionDataSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.push.parse.notification.actions; 6 | 7 | import com.fasterxml.jackson.core.JsonGenerator; 8 | import com.fasterxml.jackson.databind.JsonSerializer; 9 | import com.fasterxml.jackson.databind.SerializerProvider; 10 | import com.urbanairship.api.push.model.notification.actions.TagActionData; 11 | 12 | import java.io.IOException; 13 | 14 | public final class TagActionDataSerializer extends JsonSerializer { 15 | @Override 16 | public void serialize(TagActionData tagActionData, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException { 17 | if(tagActionData.isSingle()) { 18 | jsonGenerator.writeString(tagActionData.getSingleTag()); 19 | } 20 | else { 21 | jsonGenerator.writeStartArray(); 22 | for(String tag : tagActionData.getTagSet()) { 23 | jsonGenerator.writeString(tag); 24 | } 25 | jsonGenerator.writeEndArray(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/notification/adm/ADMFieldsDeserializer.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.push.parse.notification.adm; 2 | 3 | import com.fasterxml.jackson.core.JsonParser; 4 | import com.fasterxml.jackson.databind.DeserializationContext; 5 | import com.fasterxml.jackson.databind.JsonDeserializer; 6 | import com.urbanairship.api.push.model.notification.adm.ADMFields; 7 | 8 | import java.io.IOException; 9 | 10 | public class ADMFieldsDeserializer extends JsonDeserializer { 11 | @Override 12 | public ADMFields deserialize(JsonParser parser, DeserializationContext context) throws IOException { 13 | return parser.readValueAs(ADMFields.class); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/notification/adm/ADMTemplateDeserializer.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.push.parse.notification.adm; 2 | 3 | import com.fasterxml.jackson.core.JsonParser; 4 | import com.fasterxml.jackson.databind.DeserializationContext; 5 | import com.fasterxml.jackson.databind.JsonDeserializer; 6 | import com.urbanairship.api.push.model.notification.adm.ADMTemplate; 7 | 8 | import java.io.IOException; 9 | 10 | public class ADMTemplateDeserializer extends JsonDeserializer { 11 | @Override 12 | public ADMTemplate deserialize(JsonParser parser, DeserializationContext context) throws IOException { 13 | return parser.readValueAs(ADMTemplate.class); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/notification/android/AndroidFieldsDeserializer.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.push.parse.notification.android; 2 | 3 | import com.fasterxml.jackson.core.JsonParser; 4 | import com.fasterxml.jackson.databind.DeserializationContext; 5 | import com.fasterxml.jackson.databind.JsonDeserializer; 6 | import com.urbanairship.api.push.model.notification.android.AndroidFields; 7 | 8 | import java.io.IOException; 9 | 10 | public class AndroidFieldsDeserializer extends JsonDeserializer { 11 | @Override 12 | public AndroidFields deserialize(JsonParser parser, DeserializationContext context) throws IOException { 13 | return parser.readValueAs(AndroidFields.class); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/notification/android/AndroidTemplateDeserializer.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.push.parse.notification.android; 2 | 3 | import com.fasterxml.jackson.core.JsonParser; 4 | import com.fasterxml.jackson.databind.DeserializationContext; 5 | import com.fasterxml.jackson.databind.JsonDeserializer; 6 | import com.urbanairship.api.push.model.notification.android.AndroidTemplate; 7 | 8 | import java.io.IOException; 9 | 10 | public class AndroidTemplateDeserializer extends JsonDeserializer { 11 | @Override 12 | public AndroidTemplate deserialize(JsonParser parser, DeserializationContext context) throws IOException { 13 | return parser.readValueAs(AndroidTemplate.class); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/notification/android/CategoryDeserializer.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.push.parse.notification.android; 2 | 3 | import com.fasterxml.jackson.core.JsonParser; 4 | import com.fasterxml.jackson.databind.DeserializationContext; 5 | import com.fasterxml.jackson.databind.JsonDeserializer; 6 | import com.urbanairship.api.common.parse.APIParsingException; 7 | import com.urbanairship.api.push.model.notification.android.Category; 8 | 9 | import java.io.IOException; 10 | import java.util.Optional; 11 | 12 | public final class CategoryDeserializer extends JsonDeserializer { 13 | 14 | @Override 15 | public Category deserialize(JsonParser jp, DeserializationContext ctx) throws IOException { 16 | String categoryString = jp.getText(); 17 | Optional category = Category.find(categoryString); 18 | 19 | if (!category.isPresent()) { 20 | throw new APIParsingException("Unrecognized category " + categoryString); 21 | } 22 | 23 | return category.get(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/notification/android/PublicNotificationSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.push.parse.notification.android; 6 | 7 | import com.fasterxml.jackson.core.JsonGenerator; 8 | import com.fasterxml.jackson.databind.JsonSerializer; 9 | import com.fasterxml.jackson.databind.SerializerProvider; 10 | import com.urbanairship.api.push.model.notification.android.PublicNotification; 11 | 12 | import java.io.IOException; 13 | 14 | public class PublicNotificationSerializer extends JsonSerializer { 15 | 16 | @Override 17 | public void serialize(PublicNotification publicNotification, JsonGenerator jgen, SerializerProvider provider) throws IOException { 18 | jgen.writeStartObject(); 19 | 20 | if (publicNotification.getSummary().isPresent()) { 21 | jgen.writeStringField("summary", publicNotification.getSummary().get()); 22 | } 23 | if (publicNotification.getAlert().isPresent()) { 24 | jgen.writeStringField("alert", publicNotification.getAlert().get()); 25 | } 26 | if (publicNotification.getTitle().isPresent()) { 27 | jgen.writeStringField("title", publicNotification.getTitle().get()); 28 | 29 | } 30 | 31 | jgen.writeEndObject(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/notification/android/WearableSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.push.parse.notification.android; 6 | 7 | import com.fasterxml.jackson.core.JsonGenerator; 8 | import com.fasterxml.jackson.databind.JsonSerializer; 9 | import com.fasterxml.jackson.databind.SerializerProvider; 10 | import com.urbanairship.api.push.model.notification.android.Wearable; 11 | 12 | import java.io.IOException; 13 | 14 | public class WearableSerializer extends JsonSerializer { 15 | @Override 16 | public void serialize(Wearable payload, JsonGenerator jgen, SerializerProvider provider) throws IOException { 17 | jgen.writeStartObject(); 18 | if (payload.getBackgroundImage().isPresent()) { 19 | jgen.writeStringField("background_image", payload.getBackgroundImage().get()); 20 | } 21 | if (payload.getInteractive().isPresent()) { 22 | jgen.writeObjectField("interactive", payload.getInteractive().get()); 23 | } 24 | if (payload.getExtraPages().isPresent()) { 25 | jgen.writeObjectField("extra_pages", payload.getExtraPages().get()); 26 | } 27 | jgen.writeEndObject(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/notification/ios/CropSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | package com.urbanairship.api.push.parse.notification.ios; 5 | 6 | import com.fasterxml.jackson.core.JsonGenerator; 7 | import com.fasterxml.jackson.core.JsonProcessingException; 8 | import com.fasterxml.jackson.databind.JsonSerializer; 9 | import com.fasterxml.jackson.databind.SerializerProvider; 10 | import com.urbanairship.api.push.model.notification.ios.Crop; 11 | 12 | import java.io.IOException; 13 | 14 | public class CropSerializer extends JsonSerializer { 15 | @Override 16 | public void serialize(Crop crop, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { 17 | jgen.writeStartObject(); 18 | 19 | if (crop.getX().isPresent()) { 20 | jgen.writeObjectField("x", crop.getX().get()); 21 | } 22 | 23 | if (crop.getY().isPresent()) { 24 | jgen.writeObjectField("y", crop.getY().get()); 25 | } 26 | 27 | if (crop.getWidth().isPresent()) { 28 | jgen.writeObjectField("width", crop.getWidth().get()); 29 | } 30 | 31 | if (crop.getHeight().isPresent()) { 32 | jgen.writeObjectField("height", crop.getHeight().get()); 33 | } 34 | 35 | jgen.writeEndObject(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/notification/ios/IOSBadgeDataSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.push.parse.notification.ios; 6 | 7 | import com.fasterxml.jackson.core.JsonGenerator; 8 | import com.fasterxml.jackson.databind.JsonSerializer; 9 | import com.fasterxml.jackson.databind.SerializerProvider; 10 | import com.urbanairship.api.push.model.notification.ios.IOSBadgeData; 11 | 12 | import java.io.IOException; 13 | 14 | public class IOSBadgeDataSerializer extends JsonSerializer { 15 | @Override 16 | public void serialize(IOSBadgeData badge, JsonGenerator jgen, SerializerProvider provider) throws IOException { 17 | switch (badge.getType()) { 18 | case VALUE: 19 | jgen.writeNumber(badge.getValue().get()); 20 | break; 21 | case AUTO: 22 | jgen.writeString("auto"); 23 | break; 24 | case INCREMENT: 25 | jgen.writeString("+" + badge.getValue().get().toString()); 26 | break; 27 | case DECREMENT: 28 | jgen.writeString("-" + badge.getValue().get().toString()); 29 | break; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/notification/ios/IOSFieldsDeserializer.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.push.parse.notification.ios; 2 | 3 | import com.fasterxml.jackson.core.JsonParser; 4 | import com.fasterxml.jackson.databind.DeserializationContext; 5 | import com.fasterxml.jackson.databind.JsonDeserializer; 6 | import com.urbanairship.api.push.model.notification.ios.IOSFields; 7 | 8 | import java.io.IOException; 9 | 10 | public class IOSFieldsDeserializer extends JsonDeserializer { 11 | @Override 12 | public IOSFields deserialize(JsonParser parser, DeserializationContext context) throws IOException { 13 | return parser.readValueAs(IOSFields.class); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/notification/ios/IOSInterruptionLevelDeserializer.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.push.parse.notification.ios; 2 | 3 | import com.fasterxml.jackson.core.JsonParser; 4 | import com.fasterxml.jackson.databind.DeserializationContext; 5 | import com.fasterxml.jackson.databind.JsonDeserializer; 6 | import com.urbanairship.api.common.parse.APIParsingException; 7 | import com.urbanairship.api.push.model.notification.ios.IOSInterruptionLevel; 8 | 9 | import java.io.IOException; 10 | import java.util.Optional; 11 | 12 | public final class IOSInterruptionLevelDeserializer extends JsonDeserializer { 13 | 14 | @Override 15 | public IOSInterruptionLevel deserialize(JsonParser jp, DeserializationContext ctx) throws IOException { 16 | String iOSInterruptionLevelString = jp.getText(); 17 | Optional iosInterruptionLevel = IOSInterruptionLevel.find(iOSInterruptionLevelString); 18 | 19 | if (!iosInterruptionLevel.isPresent()) { 20 | throw new APIParsingException("Unrecognized interruption level " + iOSInterruptionLevelString); 21 | } 22 | 23 | return iosInterruptionLevel.get(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/notification/ios/IOSLiveActivityAlertSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | package com.urbanairship.api.push.parse.notification.ios; 5 | 6 | import com.fasterxml.jackson.core.JsonGenerator; 7 | import com.fasterxml.jackson.databind.JsonSerializer; 8 | import com.fasterxml.jackson.databind.SerializerProvider; 9 | import com.urbanairship.api.push.model.notification.ios.IOSLiveActivityAlert; 10 | import com.urbanairship.api.push.model.notification.ios.IOSMediaContent; 11 | 12 | import java.io.IOException; 13 | 14 | public class IOSLiveActivityAlertSerializer extends JsonSerializer { 15 | @Override 16 | public void serialize(IOSLiveActivityAlert content, JsonGenerator jgen, SerializerProvider provider) throws IOException { 17 | jgen.writeStartObject(); 18 | 19 | if(content.getBody().isPresent()) { 20 | jgen.writeStringField("body", content.getBody().get()); 21 | } 22 | 23 | if(content.getTitle().isPresent()) { 24 | jgen.writeStringField("title", content.getTitle().get()); 25 | } 26 | 27 | if(content.getSound().isPresent()) { 28 | jgen.writeStringField("sound", content.getSound().get()); 29 | } 30 | 31 | jgen.writeEndObject(); 32 | } 33 | } -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/notification/ios/IOSMediaContentSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | package com.urbanairship.api.push.parse.notification.ios; 5 | 6 | import com.fasterxml.jackson.core.JsonGenerator; 7 | import com.fasterxml.jackson.databind.JsonSerializer; 8 | import com.fasterxml.jackson.databind.SerializerProvider; 9 | import com.urbanairship.api.push.model.notification.ios.IOSMediaContent; 10 | 11 | import java.io.IOException; 12 | 13 | public class IOSMediaContentSerializer extends JsonSerializer { 14 | @Override 15 | public void serialize(IOSMediaContent content, JsonGenerator jgen, SerializerProvider provider) throws IOException { 16 | jgen.writeStartObject(); 17 | 18 | if(content.getBody().isPresent()) { 19 | jgen.writeStringField("body", content.getBody().get()); 20 | } 21 | 22 | if(content.getTitle().isPresent()) { 23 | jgen.writeStringField("title", content.getTitle().get()); 24 | } 25 | 26 | if(content.getSubtitle().isPresent()) { 27 | jgen.writeStringField("subtitle", content.getSubtitle().get()); 28 | } 29 | 30 | jgen.writeEndObject(); 31 | } 32 | } -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/notification/ios/IOSMediaOptionsSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | package com.urbanairship.api.push.parse.notification.ios; 5 | 6 | import com.fasterxml.jackson.core.JsonGenerator; 7 | import com.fasterxml.jackson.core.JsonProcessingException; 8 | import com.fasterxml.jackson.databind.JsonSerializer; 9 | import com.fasterxml.jackson.databind.SerializerProvider; 10 | import com.urbanairship.api.push.model.notification.ios.IOSMediaOptions; 11 | 12 | import java.io.IOException; 13 | 14 | public class IOSMediaOptionsSerializer extends JsonSerializer { 15 | 16 | @Override 17 | public void serialize(IOSMediaOptions options, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { 18 | jgen.writeStartObject(); 19 | 20 | if(options.getTime().isPresent()) { 21 | jgen.writeObjectField("time", options.getTime().get()); 22 | } 23 | 24 | if(options.getCrop().isPresent()) { 25 | jgen.writeObjectField("crop", options.getCrop().get()); 26 | } 27 | 28 | if(options.getHidden().isPresent()) { 29 | jgen.writeBooleanField("hidden", options.getHidden().get()); 30 | } 31 | 32 | jgen.writeEndObject(); 33 | } 34 | } -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/notification/ios/IOSSoundDataSerializer.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.push.parse.notification.ios; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.databind.JsonSerializer; 5 | import com.fasterxml.jackson.databind.SerializerProvider; 6 | import com.urbanairship.api.push.model.notification.ios.IOSSoundData; 7 | 8 | import java.io.IOException; 9 | 10 | public class IOSSoundDataSerializer extends JsonSerializer { 11 | @Override 12 | public void serialize(IOSSoundData payload, JsonGenerator jgen, SerializerProvider provider) throws IOException { 13 | if (!payload.shouldBeDict()) { 14 | jgen.writeString(payload.getName().get()); 15 | } else { 16 | jgen.writeStartObject(); 17 | 18 | if (payload.getCritical().isPresent()) { 19 | jgen.writeBooleanField("critical", payload.getCritical().get()); 20 | } 21 | 22 | if (payload.getVolume().isPresent()) { 23 | jgen.writeNumberField("volume", payload.getVolume().get()); 24 | } 25 | 26 | if (payload.getName().isPresent()) { 27 | jgen.writeStringField("name", payload.getName().get()); 28 | } 29 | 30 | jgen.writeEndObject(); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/notification/ios/IOSTemplateDeserializer.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.push.parse.notification.ios; 2 | 3 | import com.fasterxml.jackson.core.JsonParser; 4 | import com.fasterxml.jackson.databind.DeserializationContext; 5 | import com.fasterxml.jackson.databind.JsonDeserializer; 6 | import com.urbanairship.api.push.model.notification.ios.IOSTemplate; 7 | 8 | import java.io.IOException; 9 | 10 | public class IOSTemplateDeserializer extends JsonDeserializer { 11 | @Override 12 | public IOSTemplate deserialize(JsonParser parser, DeserializationContext context) throws IOException { 13 | return parser.readValueAs(IOSTemplate.class); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/notification/ios/MediaAttachmentSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | package com.urbanairship.api.push.parse.notification.ios; 5 | 6 | 7 | import com.fasterxml.jackson.core.JsonGenerator; 8 | import com.fasterxml.jackson.databind.JsonSerializer; 9 | import com.fasterxml.jackson.databind.SerializerProvider; 10 | import com.urbanairship.api.push.model.notification.ios.MediaAttachment; 11 | 12 | import java.io.IOException; 13 | 14 | public class MediaAttachmentSerializer extends JsonSerializer { 15 | @Override 16 | public void serialize(MediaAttachment mediaAttachment, JsonGenerator jgen, SerializerProvider provider) throws IOException { 17 | jgen.writeStartObject(); 18 | 19 | jgen.writeStringField("url", mediaAttachment.getUrl()); 20 | 21 | if(mediaAttachment.getOptions().isPresent()) { 22 | jgen.writeObjectField("options", mediaAttachment.getOptions().get()); 23 | } 24 | 25 | if(mediaAttachment.getContent().isPresent()){ 26 | jgen.writeObjectField("content", mediaAttachment.getContent().get()); 27 | } 28 | 29 | jgen.writeEndObject(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/notification/richpush/RichPushIconReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.push.parse.notification.richpush; 6 | 7 | import com.fasterxml.jackson.core.JsonParser; 8 | import com.urbanairship.api.common.parse.APIParsingException; 9 | import com.urbanairship.api.common.parse.JsonObjectReader; 10 | import com.urbanairship.api.common.parse.StringFieldDeserializer; 11 | import com.urbanairship.api.push.model.notification.richpush.RichPushIcon; 12 | 13 | import java.io.IOException; 14 | 15 | public class RichPushIconReader implements JsonObjectReader { 16 | 17 | private RichPushIcon.Builder builder = RichPushIcon.newBuilder(); 18 | 19 | public RichPushIconReader() { 20 | } 21 | 22 | public void readListIcon(JsonParser parser) throws IOException { 23 | builder.setListIcon(StringFieldDeserializer.INSTANCE.deserialize(parser, "list_icon")); 24 | } 25 | 26 | @Override 27 | public RichPushIcon validateAndBuild() throws IOException { 28 | try { 29 | return builder.build(); 30 | } catch (Exception e) { 31 | throw new APIParsingException(e.getMessage(), e); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/notification/richpush/RichPushIconSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016. Urban Airship and Contributors 3 | */ 4 | 5 | package com.urbanairship.api.push.parse.notification.richpush; 6 | 7 | import com.fasterxml.jackson.core.JsonGenerator; 8 | import com.fasterxml.jackson.databind.JsonSerializer; 9 | import com.fasterxml.jackson.databind.SerializerProvider; 10 | import com.urbanairship.api.push.model.notification.richpush.RichPushIcon; 11 | 12 | import java.io.IOException; 13 | 14 | public class RichPushIconSerializer extends JsonSerializer { 15 | @Override 16 | public void serialize(RichPushIcon icon, JsonGenerator jgen, SerializerProvider provider) throws IOException { 17 | jgen.writeStartObject(); 18 | jgen.writeStringField("list_icon", icon.getListIcon()); 19 | jgen.writeEndObject(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/notification/sms/SmsPayloadReader.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.push.parse.notification.sms; 2 | 3 | import com.fasterxml.jackson.core.JsonParser; 4 | import com.urbanairship.api.common.parse.APIParsingException; 5 | import com.urbanairship.api.common.parse.JsonObjectReader; 6 | import com.urbanairship.api.common.parse.StringFieldDeserializer; 7 | import com.urbanairship.api.push.model.PushExpiry; 8 | import com.urbanairship.api.push.model.notification.sms.SmsPayload; 9 | 10 | import java.io.IOException; 11 | 12 | public class SmsPayloadReader implements JsonObjectReader { 13 | 14 | private SmsPayload.Builder builder; 15 | 16 | public SmsPayloadReader() { 17 | this.builder = SmsPayload.newBuilder(); 18 | } 19 | 20 | public void readAlert(JsonParser parser) throws IOException { 21 | builder.setAlert(StringFieldDeserializer.INSTANCE.deserialize(parser, "alert")); 22 | } 23 | 24 | public void readPushExpiry(JsonParser parser) throws IOException { 25 | builder.setExpiry(parser.readValueAs(PushExpiry.class)); 26 | } 27 | 28 | @Override 29 | public SmsPayload validateAndBuild() throws IOException { 30 | try { 31 | return builder.build(); 32 | } catch (Exception e) { 33 | throw new APIParsingException(e.getMessage(), e); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/notification/sms/SmsPayloadSerializer.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.push.parse.notification.sms; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.databind.JsonSerializer; 5 | import com.fasterxml.jackson.databind.SerializerProvider; 6 | import com.urbanairship.api.push.model.notification.sms.SmsPayload; 7 | 8 | import java.io.IOException; 9 | 10 | public class SmsPayloadSerializer extends JsonSerializer { 11 | @Override 12 | public void serialize(SmsPayload payload, JsonGenerator jgen, SerializerProvider provider) throws IOException { 13 | jgen.writeStartObject(); 14 | 15 | if (payload.getAlert().isPresent()) { 16 | jgen.writeStringField("alert", payload.getAlert().get()); 17 | } 18 | 19 | if (payload.getExpiry().isPresent()) { 20 | jgen.writeObjectField("expiry", payload.getExpiry().get()); 21 | } 22 | 23 | jgen.writeEndObject(); 24 | } 25 | } -------------------------------------------------------------------------------- /src/main/java/com/urbanairship/api/push/parse/notification/web/ButtonSerializer.java: -------------------------------------------------------------------------------- 1 | package com.urbanairship.api.push.parse.notification.web; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.databind.JsonSerializer; 5 | import com.fasterxml.jackson.databind.SerializerProvider; 6 | import com.urbanairship.api.push.model.notification.web.Button; 7 | 8 | import java.io.IOException; 9 | 10 | public class ButtonSerializer extends JsonSerializer