GithubHelp home page GithubHelp logo

novaposhta2's Introduction

Novaposhta API 2.0

Ruby gem for Nova Poshta API 2.0. Nova Poshta is a popular local shipping provider in Ukraine (https://novaposhta.ua/), also known as "Нова Пошта" and "Новая Почта".

Installation

Add the gem to your Gemfile:

gem 'novaposhta2', github: 'kukareka/novaposhta2'

And don't forget to run Bundler:

bundle install

Configuration

Store API key and sender credentials in app/config/initializers/novaposhta2.rb:

Novaposhta2.configure do |config|
    config.api_key = 'Your api key'
    config.sender = {
        ref: 'Sender reference',
        city: 'City reference',
        address: 'Sender warehouse reference',
        contact: 'Sender contact reference',
        phone: 'Sender phone',
    }
end

You can get your own credentials on https://novaposhta.ua/.

Usage

Manage cities:

Novaposhta2::City.all # list all cities

Novaposhta2::City.find('Киев') # find city by name
Novaposhta2::City['Киев'] # the same
Novaposhta2['Киев'] # the same

Novaposhta2::City.match('К') # return list of cities starting with 'К'

Manage warehouses:

Novaposhta2['Киев'].warehouses # list all warehouses in Kiev city
Novaposhta2['Киев'][2] # warehouse number 2 in Kiev city

Manage packages:

# create package for Ivan Ivanov, shipping to warehouse number 2 in Kiev.
package = Novaposhta2['Киев'].person('Иван', 'Иванов', '380631234567').
    package(Novaposhta2['Киев'][2], volume: 0.04, cost: 100, description: 'Бомба')

package.rate # check shipping rate in UAH
package.save # commit the package

package.tracking # get tracking number
package.print # URL to print marking

package.track # track the package
Novaposhta2::Package.track('123456789') # track a package by tracking number
Novaposhta2.track('123456789') # the same

Package options

#####cost Mandatory. Cost of the package contents, for insurance needs. #####description Mandatory. Description of package contents. #####internal_number Internal order number. #####payer_type Sender of Recipient. Default: Sender. #####payment_method Cash or NonCash. Default: Cash. #####seats Number of boxes. Default: 1. #####volume Mandatory. Volume of the package in cm. #####weight Mandatory. Weight of the package in kg.

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.