Class: Craigslist::API::BulkTransport
- Inherits:
-
Object
- Object
- Craigslist::API::BulkTransport
- Defined in:
- lib/craigslist/api/bulk_transport.rb
Overview
Submits postings to the RSS bulk interface.
Validate and post take identical documents and differ only in the URL, so validating is a genuine dry run of the exact payload that would be posted.
Constant Summary collapse
- CONTENT_TYPE =
The protocol section of the documentation asks for text/xml. The changelog mentions application/xml and the sample client still sends form encoding; text/xml is the one the protocol itself specifies.
"text/xml; charset=utf-8"- VALIDATE_PATH =
Dry-run endpoint. Takes the same document as POST_PATH.
"/bulk-rss/validate"- POST_PATH =
Endpoint that actually creates postings.
"/bulk-rss/post"
Instance Method Summary collapse
-
#initialize(config:, connection:) ⇒ BulkTransport
constructor
A new instance of BulkTransport.
-
#post(postings) ⇒ ResultSet
Creates the postings.
-
#validate(postings) ⇒ ResultSet
Dry run: checks the document without creating anything.
Constructor Details
#initialize(config:, connection:) ⇒ BulkTransport
Returns a new instance of BulkTransport.
21 22 23 24 25 |
# File 'lib/craigslist/api/bulk_transport.rb', line 21 def initialize(config:, connection:) @config = config @connection = connection @serializer = Serializer.new(config) end |
Instance Method Details
#post(postings) ⇒ ResultSet
Creates the postings.
39 40 41 |
# File 'lib/craigslist/api/bulk_transport.rb', line 39 def post(postings) submit(POST_PATH, postings) end |
#validate(postings) ⇒ ResultSet
Dry run: checks the document without creating anything.
31 32 33 |
# File 'lib/craigslist/api/bulk_transport.rb', line 31 def validate(postings) submit(VALIDATE_PATH, postings) end |