No release in over a year
Faraday middleware for encoding requests as XML.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

~> 2.3
~> 1.3
 Project Readme

Faraday Encode XML

Cirrus CI - Base Branch Build Status Codecov branch Code Climate Depfu Gem License

This repo is a Faraday middleware for encoding requests as XML. Faraday is an HTTP client library that provides a common interface for making requests.

Installation

Add this line to your application's Gemfile:

gem 'faraday-encode_xml'

And then execute:

bundle install

Or install it yourself as:

gem install faraday-encode_xml

Usage

require 'faraday/encode_xml'

connection = Faraday.new do |faraday|
  ## This gem only encodes requests
  faraday.request :xml

  ## For responses deconding use `faraday_middleware` gem and such code:
  # require 'faraday_middleware'
  # faraday.response :xml

  ## For example `httpbingo` responses as JSON, so let's enable it:
  require 'faraday_middleware'
  faraday.response :json
end

response = connection.post('https://httpbingo.org/post', { a: 1, b: 'foo', c: true })

puts response.body['data'] ## => <a>1</a><b>foo</b><c>true</c>

Gyoku options

The middleware uses gyoku gem for XML encoding.

You can pass options for it:

connection = Faraday.new do |faraday|
  ## https://www.rubydoc.info/gems/gyoku/#array-values
  faraday.request :xml, gyoku_options: { unwrap: true }
end

Development

After checking out the repo, run bundle install to install dependencies.

Then, run bundle exec rspec to run the tests.

To install this gem onto your local machine, run toys gem install.

To release a new version, run toys gem release %version%. See how it works here.

Contributing

Bug reports and pull requests are welcome on GitHub.

License

The gem is available as open source under the terms of the MIT License.