Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alejandrodevs/iso-8583
ISO 8583 Financial Messaging for Ruby
https://github.com/alejandrodevs/iso-8583
Last synced: 10 days ago
JSON representation
ISO 8583 Financial Messaging for Ruby
- Host: GitHub
- URL: https://github.com/alejandrodevs/iso-8583
- Owner: alejandrodevs
- License: mit
- Created: 2015-05-18T15:27:25.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-05-26T22:39:46.000Z (over 9 years ago)
- Last Synced: 2024-10-31T05:51:42.976Z (17 days ago)
- Language: Ruby
- Homepage:
- Size: 230 KB
- Stars: 8
- Watchers: 4
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# ISO 8583
[![Build Status](https://travis-ci.org/alejandrogutierrez/iso-8583.png?branch=master)](https://travis-ci.org/alejandrogutierrez/iso-8583) [![Coverage Status](https://coveralls.io/repos/alejandrogutierrez/iso-8583/badge.svg?branch=master)](https://coveralls.io/r/alejandrogutierrez/iso-8583?branch=master)ISO 8583 Financial Messaging for Ruby. This gem aims to provide a easy
and simple way to encode and decode ISO 8583 Financial Messages.## Installation
Add this line to your Gemfile:
```ruby
gem 'iso-8583'
```
Run the bundle command to install it.## Usage
### Decoding a ISO 8583 message
```ruby
require 'iso8583'message = ISO8583::Message.new('ISO02110005508100220000002000000082108321601579500301')
# Getting properties.
message.header # =>
message.mti # =>
message.bitmap # =>
message.data # =># Getting fields.
message.fields.ids # => [7, 11, 39]
message.fields[7] # =>
message.fields[7].id # => 7
message.fields[7].data # => "0821083216"
message.fields[7].value # => "0821083216"
message.fields[7].length # => 10
message.fields[7].codec # => /^[0-9]*$/
message.fields[7].type # =>
```### Encoding a ISO 8583 message
```ruby
require 'iso8583'message = ISO8583::Message.new
# Setting properties.
message.header = 'ISO021100055' #Optional
message.mti = '0810'# Adding fields.
message.set_field(7, '0821083216') # =>
message.set_field(11, '015795') # =>
message.set_field(39, '00') # =># Deleting fields.
message.unset_field(11) # => 11
message.unset_field(39) # => 39# Getting full message.
message.bitmap # =>
message.to_s # => "ISO021100055081002000000000000000821083216"
```### Exceptions
```ruby
require 'iso8583'message = ISO8583::Message.new
# Raising exceptions.
message.mti = '02000' # => ISO8583::ISO8583LengthException: Must have length == 4
message.mti = '020A' # => ISO8583::ISO8583CodecException: Must match /^[0-9]*$/
message.header = 'ISO02' # => ISO8583::ISO8583LengthException: Must have length == 12# ISO 8583 defines that data element 11 must be numeric and have length of 6.
message.set_field(11, '01579A') # => ISO8583::ISO8583CodecException: Must match /^[0-9]*$/
message.set_field(11, '01579') # => ISO8583::ISO8583LengthException: Must have length == 6
message.set_field(11, '015795') # => OK
```## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new pull request