Giter Site home page Giter Site logo

russianpost's Introduction

Russian Post API Client

Build Status Code Climate Gem Version

Ruby client for Russian Post package tracking SOAP API. Works on a per-package basis (contrary to the bulk ticket-based API). The client tries to be smart and fills gaps in the information provided by Russian Post using external knowledge.

Use it at your own risk, since the API may appear unstable and require authorization in future.

Installation

To install gem stand-alone:

gem install russianpost

To use gem in a Rails app, add the following to your Gemfile:

gem 'russianpost', '~> 0.7.0'

This gem uses Savon, which in turn uses HTTPI internally. HTTPI chooses the best HTTP library of those you have installed. For the best performance add Curb to your Gemfile:

gem 'curb'
gem 'russianpost'

If you use RussianPost outside Rails, require 'curb' before requiring RussianPost.

Usage

Initialize a parcel object, passing the package barcode to the constructor:

parcel = RussianPost::Parcel.new('EC123456789RU')

Fetch operation history for the parcel:

parcel.operations

The operations method returns an Array of Operation structs.

Parcel info

RussianPost makes guesses about current state of the parcel.

# Current parcel location
parcel.location

# Mass
parcel.mass

# Rank
parcel.rank

# Recipient
parcel.recipient

# Type
parcel.type

Barcode validator

You can use the included barcode validator separately. It not only validates the format of a barcode, but also calculates check digits and tests barcodes against them.

barcode = RussianPost::Barcode.new('EC123456789RU')
barcode.valid? #=> false

barcode = RussianPost::Barcode.new('RD025500807SE')
barcode.valid? #=> true

Operations API

Each Operation responds to the following methods. If there is no information, methods return nil. See the wiki for a list of what else can be returned.

Address parameters

destination_address              #=> RussianPost::Address (Struct)
destination_address.index        #=> String
destination_address.description  #=> String

operation_address                #=> RussianPost::Address (Struct)
operation_address.index          #=> String
operation_address.description    #=> String

mail_direct                      #=> RussianPost::Country (Struct)
mail_direct.id                   #=> Fixnum
mail_direct.code_2a              #=> String
mail_direct.code_3a              #=> String
mail_direct.name_ru              #=> String
mail_direct.name_en              #=> String

country_from                     #=> RussianPost::Country (Struct)
country_from.id                  #=> Fixnum
country_from.code_2a             #=> String
country_from.code_3a             #=> String
country_from.name_ru             #=> String
country_from.name_en             #=> String

country_oper                     #=> RussianPost::Country (Struct)
country_oper.id                  #=> Fixnum
country_oper.code_2a             #=> String
country_oper.code_3a             #=> String
country_oper.name_ru             #=> String
country_oper.name_en             #=> String

Finance parameters

payment                          #=> Fixnum
value                            #=> Fixnum
mass_rate                        #=> Fixnum
insr_rate                        #=> Fixnum
air_rate                         #=> Fixnum
rate                             #=> Fixnum

Item parameters

barcode                          #=> String
internum                         #=> String
valid_ru_type                    #=> Boolean
valid_en_type                    #=> Boolean
complex_item_name                #=> String

mail_rank                        #=> RussianPost::GenericOperationParameter (Struct)
mail_rank.id                     #=> Fixnum
mail_rank.name                   #=> String

post_mark                        #=> RussianPost::GenericOperationParameter (Struct)
post_mark.id                     #=> Fixnum
post_mark.name                   #=> String

mail_type                        #=> RussianPost::GenericOperationParameter (Struct)
mail_type.id                     #=> Fixnum
mail_type.name                   #=> String

mail_ctg                         #=> RussianPost::GenericOperationParameter (Struct)
mail_ctg.id                      #=> Fixnum
mail_ctg.name                    #=> String

mass                             #=> Fixnum
max_mass_ru                      #=> Fixnum
max_mass_en                      #=> Fixnum

Operation parameters

oper_type                        #=> RussianPost::GenericOperationParameter (Struct)
oper_type.id                     #=> Fixnum
oper_type.name                   #=> String

oper_attr                        #=> RussianPost::GenericOperationParameter (Struct)
oper_attr.id                     #=> Fixnum
oper_attr.name                   #=> String

oper_date                        #=> DateTime

User parameters

send_ctg                         #=> RussianPost::GenericOperationParameter (Struct)
send_ctg.id                      #=> Fixnum
send_ctg.name                    #=> String

sndr                             #=> String
rcpn                             #=> String

russianpost's People

Contributors

artemshitov avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.