View Source ExPorterSDK

Hex.pm Docs License

An Elixir SDK for Porter's delivery API, providing a simple and reliable way to integrate Porter's logistics services into your Elixir applications.

Features

  • ๐Ÿšš Get delivery quotes based on locations
  • ๐Ÿ“ฆ Create and manage delivery orders
  • ๐Ÿ” Track order status in real-time
  • โšก Simple and intuitive API
  • ๐Ÿงช Comprehensive test coverage
  • ๐Ÿ“š Well-documented codebase

Installation

Add ex_porter_sdk to your list of dependencies in mix.exs:

def deps do
  [
    {:ex_porter_sdk, "~> 0.1.0"}
  ]
end

Configuration

Configure the SDK in your config.exs:

config :ex_porter_sdk,
  base_url: System.get_env("PORTER_BASE_URL", "https://api.porter.in"),
  api_key: System.get_env("PORTER_API_KEY")

Quick Start

Get Delivery Quote

params = %{
  pickup_details: %{lat: 12.909728534457143, lng: 77.6001397394293},
  drop_details: %{lat: 12.89795704454522, lng: 77.62119799020186},
  customer: %{
    name: "Test User",
    mobile: %{number: "7678139714", country_code: "+91"}
  }
}

{:ok, response} = ExPorterSDK.Quote.get_quote(params)

Create Order

order_params = %{
  request_id: "unique-request-id",
  pickup_details: %{
    address: %{
      apartment_address: "27",
      street_address1: "Main Street",
      city: "Bengaluru",
      state: "Karnataka",
      pincode: "560029",
      country: "India",
      lat: 12.939391726766775,
      lng: 77.62629462844717,
      contact_details: %{
        name: "Test User",
        phone_number: "+911234567890"
      }
    }
  },
  drop_details: %{
    # Similar structure as pickup_details
  }
}

{:ok, response} = ExPorterSDK.Order.create(order_params)

Track Order

{:ok, status} = ExPorterSDK.Order.track("order_id")

Cancel Order

{:ok, response} = ExPorterSDK.Order.cancel("order_id")

Documentation

Detailed documentation is available at https://hexdocs.pm/ex_porter_sdk.

Testing

The SDK includes comprehensive tests. Run them with:

mix test

For development and testing, use the provided stubs:

# config/test.exs
config :ex_porter_sdk,
  quote_impl: ExPorterSDK.Quote.Stub,
  order_impl: ExPorterSDK.Order.Stub

Contributing

We appreciate all contributions. See our Contributing Guide for details.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Support

  • Open an issue for bug reports or feature requests
  • For detailed questions, please email yatender[dot]nitk[at]gmail[dot]com

Acknowledgments