<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns="http://www.springframework.org/schema/integration/twitter"
			xmlns:xsd="http://www.w3.org/2001/XMLSchema"
			xmlns:beans="http://www.springframework.org/schema/beans"
			xmlns:tool="http://www.springframework.org/schema/tool"
			xmlns:integration="http://www.springframework.org/schema/integration"
			targetNamespace="http://www.springframework.org/schema/integration/twitter"
			elementFormDefault="qualified"
			attributeFormDefault="unqualified">

	<xsd:import namespace="http://www.springframework.org/schema/beans"/>
	<xsd:import namespace="http://www.springframework.org/schema/tool"/>
	<xsd:import namespace="http://www.springframework.org/schema/integration"
				schemaLocation="https://www.springframework.org/schema/integration/spring-integration.xsd"/>

	<!--
		INBOUND
	-->

	<xsd:element name="inbound-channel-adapter">
		<xsd:annotation>
			<xsd:documentation>
				Defines a Polling Channel Adapter for the
				'org.springframework.integration.twitter.inbound.TimelineReceivingMessageSource' that consumes your
				friends' timeline updates from Twitter and sends Messages whose payloads are Tweet objects.
			</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType >
			<xsd:complexContent>
				<xsd:extension base="inbound-twitter-type"/>
			</xsd:complexContent>
		</xsd:complexType>
	</xsd:element>

	<xsd:element name="mentions-inbound-channel-adapter">
		<xsd:annotation>
			<xsd:documentation>
				Defines a Polling Channel Adapter for the
				'org.springframework.integration.twitter.inbound.MentionsReceivingMessageSource' that consumes mentions
				of your handle from Twitter and sends Messages whose payloads are Tweet objects.
			</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:complexContent>
				<xsd:extension base="inbound-twitter-type"/>
			</xsd:complexContent>
		</xsd:complexType>
	</xsd:element>


	<xsd:element name="search-inbound-channel-adapter">
		<xsd:annotation>
			<xsd:documentation>
				Defines a Polling Channel Adapter for the
				'org.springframework.integration.twitter.inbound.SearchReceivingMessageSource' that consumes search
				results for a given query from Twitter and sends Messages whose payloads are Tweet objects.
			</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:complexContent>
				<xsd:extension base="inbound-twitter-type">
					<xsd:attribute name="query" type="xsd:string" use="required">
						<xsd:annotation>
							<xsd:documentation>
							Twitter search query (e.g, #springintegration).
							For more info on Twitter queries please refer to this site: https://search.twitter.com/operators)
							</xsd:documentation>
						</xsd:annotation>
					</xsd:attribute>
				</xsd:extension>
			</xsd:complexContent>
		</xsd:complexType>
	</xsd:element>

	<xsd:element name="dm-inbound-channel-adapter">
		<xsd:annotation>
			<xsd:documentation>
				Defines a Polling Channel Adapter for the
				'org.springframework.integration.twitter.inbound.DirectMessageReceivingMessageSource' that consumes
				direct messages from Twitter and sends Messages whose payloads are DirectMessage objects.
			</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:complexContent>
				<xsd:extension base="inbound-twitter-type"/>
			</xsd:complexContent>
		</xsd:complexType>
	</xsd:element>

	<!--
		OUTBOUND
	-->

	<xsd:element name="dm-outbound-channel-adapter">
		<xsd:annotation>
			<xsd:documentation>
				Configures a Consumer Endpoint for the
				'org.springframework.integration.twitter.outbound.DirectMessageSendingMessageHandler'
				that sends Direct Messages to a Twitter user as
				specified in the header whose name is defined by the TwitterHeaders.DM_TARGET_USER_ID constant.
			</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:complexContent>
				<xsd:extension base="outbound-twitter-type">
					<xsd:attributeGroup ref="integration:channelAdapterAttributes"/>
				</xsd:extension>
			</xsd:complexContent>
		</xsd:complexType>
	</xsd:element>


	<xsd:element name="outbound-channel-adapter">
		<xsd:annotation>
			<xsd:documentation>
				Configures a Consumer Endpoint for the
				'org.springframework.integration.twitter.outbound.StatusUpdatingMessageHandler'
				that posts a status update to the authorized user's timeline.
			</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:complexContent>
				<xsd:extension base="outbound-twitter-type">
					<xsd:attribute name="tweet-data-expression" type="xsd:string">
						<xsd:annotation>
							<xsd:documentation>
								A SpEL expression that evaluates to tweetData; the evaluation result type can be
								an 'org.springframework.social.twitter.api.TweetData', a 'String' or
								'org.springframework.social.twitter.api.Tweet'.
								Default: "payload".
							</xsd:documentation>
						</xsd:annotation>
					</xsd:attribute>
					<xsd:attributeGroup ref="integration:channelAdapterAttributes"/>
				</xsd:extension>
			</xsd:complexContent>
		</xsd:complexType>
	</xsd:element>

	<xsd:element name="search-outbound-gateway">
		<xsd:annotation>
			<xsd:documentation><![CDATA[
				Configures a Consumer Endpoint for the
				'org.springframework.integration.twitter.outbound.TwitterSearchOutboundGateway'
				that issues Twitter searches and produces their results.
			]]></xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:complexContent>
				<xsd:extension base="outbound-twitter-type">
					<xsd:attribute name="id" type="xsd:string">
						<xsd:annotation>
							<xsd:documentation>
								The bean id of this gateway; the MessageHandler is also registered with this id
								plus a suffix '.handler'.
							</xsd:documentation>
						</xsd:annotation>
					</xsd:attribute>
					<xsd:attribute name="search-args-expression" type="xsd:string">
						<xsd:annotation>
							<xsd:documentation>
								A SpEL expression that evaluates to search arguments; the evaluation result type can be
								an 'org.springframework.social.twitter.api.SearchParameters', a 'String', in
								which case the default page size of 20 is used, or the expression can evaluate to
								a list of search
								arguments, for example: "{payload, headers.pageSize, headers.sinceId, headers.maxId}".
								Default: "payload".
							</xsd:documentation>
						</xsd:annotation>
					</xsd:attribute>
					<xsd:attribute name="request-channel" use="required" type="xsd:string">
						<xsd:annotation>
							<xsd:appinfo>
								<tool:annotation kind="ref">
									<tool:expected-type
										type="org.springframework.messaging.MessageChannel" />
								</tool:annotation>
							</xsd:appinfo>
							<xsd:documentation>
								Identifies the request channel attached to this gateway.
							</xsd:documentation>
						</xsd:annotation>
					</xsd:attribute>
					<xsd:attribute name="reply-channel" type="xsd:string">
						<xsd:annotation>
							<xsd:appinfo>
								<tool:annotation kind="ref">
									<tool:expected-type
										type="org.springframework.messaging.MessageChannel" />
								</tool:annotation>
							</xsd:appinfo>
							<xsd:documentation>
								Identifies the reply channel attached to this
								gateway.
							</xsd:documentation>
						</xsd:annotation>
					</xsd:attribute>
					<xsd:attribute name="reply-timeout" type="xsd:string">
						<xsd:annotation>
							<xsd:documentation><![CDATA[
								Allows you to specify how long this gateway will wait for
								the reply message to be sent successfully to the reply channel
								before throwing an exception. This attribute only applies when the
								channel might block, for example when using a bounded queue channel that
								is currently full.

								Also, keep in mind that when sending to a DirectChannel, the
								invocation will occur in the sender's thread. Therefore,
								the failing of the send operation may be caused by other
								components further downstream.

								The "reply-timeout" attribute maps to the "sendTimeout" property of the
								underlying 'MessagingTemplate' instance (org.springframework.integration.core.MessagingTemplate).

								The attribute will default, if not specified, to '-1', meaning that
								by default, the Gateway will wait indefinitely. The value is
								specified in milliseconds.
							]]></xsd:documentation>
						</xsd:annotation>
					</xsd:attribute>
					<xsd:attributeGroup ref="integration:smartLifeCycleAttributeGroup"/>
				</xsd:extension>
			</xsd:complexContent>
		</xsd:complexType>
	</xsd:element>

	<!--
		BASE TYPES
	-->

	<xsd:complexType name="inbound-twitter-type">
		<xsd:sequence>
				<xsd:element ref="integration:poller" minOccurs="0" maxOccurs="1" />
		</xsd:sequence>
		<xsd:attribute name="id" type="xsd:string" use="required">
			<xsd:annotation>
				<xsd:documentation>
					The bean id of this Polling Endpoint; the MessageSource is also registered with this id
					plus a suffix '.source'; also used as the
					MetaDataStore key with suffix '.' + the profileId from the authorized Twitter user.
				</xsd:documentation>
			</xsd:annotation>
		</xsd:attribute>
		<xsd:attribute name="channel" type="xsd:string">
			<xsd:annotation>
				<xsd:appinfo>
					<tool:annotation kind="ref">
						<tool:expected-type type="org.springframework.messaging.MessageChannel" />
					</tool:annotation>
				</xsd:appinfo>
				<xsd:documentation>
					Identifies the channel the attached to this adapter, to which messages will be sent.
				</xsd:documentation>
			</xsd:annotation>
		</xsd:attribute>
		<xsd:attributeGroup ref="integration:smartLifeCycleAttributeGroup"/>
		<xsd:attribute name="twitter-template" type="xsd:string" use="required">
			<xsd:annotation>
				<xsd:appinfo>
					<tool:annotation kind="ref">
						<tool:expected-type type="org.springframework.social.twitter.api.Twitter"/>
					</tool:annotation>
				</xsd:appinfo>
				<xsd:documentation>
					Reference to a TwitterTemplate bean provided by the Spring Social project.
				</xsd:documentation>
			</xsd:annotation>
		</xsd:attribute>
		<xsd:attribute name="metadata-store" use="optional" type="xsd:string">
			<xsd:annotation>
				<xsd:documentation>
					Reference to a MetadataStore instance for storing metadata associated with
					the retrieved feeds. If the implementation is persistent, it can help to
					prevent duplicates between restarts. If shared, it can help coordinate multiple
					instances of an adapter across different processes.
				</xsd:documentation>
				<xsd:appinfo>
					<tool:annotation kind="ref">
						<tool:expected-type type="org.springframework.integration.metadata.MetadataStore" />
					</tool:annotation>
				</xsd:appinfo>
			</xsd:annotation>
		</xsd:attribute>
		<xsd:attribute name="page-size" type="xsd:string">
			<xsd:annotation>
				<xsd:documentation>
					Limits the number of tweets retrieved on each poll; default: 20.
				</xsd:documentation>
			</xsd:annotation>
		</xsd:attribute>
	</xsd:complexType>

	<xsd:complexType name="outbound-twitter-type">
		<xsd:choice minOccurs="0" maxOccurs="2">
			<xsd:element name="transactional" type="integration:transactionalType" minOccurs="0" maxOccurs="1" />
			<xsd:element name="request-handler-advice-chain" type="integration:handlerAdviceChainType"
						 minOccurs="0" maxOccurs="1" />
			<xsd:element ref="integration:poller" minOccurs="0" maxOccurs="1"/>
		</xsd:choice>
		<xsd:attribute name="twitter-template" use="required" type="xsd:string">
			<xsd:annotation>
				<xsd:appinfo>
					<tool:annotation kind="ref">
						<tool:expected-type type="org.springframework.social.twitter.api.Twitter"/>
					</tool:annotation>
				</xsd:appinfo>
				<xsd:documentation>
					Reference to a TwitterTemplate bean provided by the Spring Social project.
				</xsd:documentation>
			</xsd:annotation>
		</xsd:attribute>
		<xsd:attribute name="order">
			<xsd:annotation>
				<xsd:documentation>
					Specifies the order for invocation when this endpoint is connected as a
					subscriber to a SubscribableChannel.
				</xsd:documentation>
			</xsd:annotation>
		</xsd:attribute>
	</xsd:complexType>

</xsd:schema>
