ExPorterSDK

Hex.pmDocsLicense

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

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

Acknowledgments

Contributing to ExPorterSDK

First off, thanks for taking the time to contribute! ๐ŸŽ‰ ๐Ÿ‘

The following is a set of guidelines for contributing to ExPorterSDK. These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request.

Code of Conduct

This project and everyone participating in it is governed by our Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to [your-email].

How Can I Contribute?

Reporting Bugs

Before creating bug reports, please check the issue list as you might find out that you don't need to create one. When you are creating a bug report, please include as many details as possible:

Suggesting Enhancements

Enhancement suggestions are tracked as GitHub issues. When creating an enhancement suggestion, please include:

Pull Requests

Development Setup

  1. Fork and clone the repo
  2. Run mix deps.get to install dependencies
  3. Run mix test to run tests

Styleguides

Git Commit Messages

Elixir Styleguide

Documentation Styleguide

Testing

Test Coverage

We strive to maintain high test coverage. Please ensure your contributions include appropriate tests.

Additional Notes

Issue and Pull Request Labels

This section lists the labels we use to help us track and manage issues and pull requests.

Getting Help

If you need help, you can:

Recognition

Contributors who add significant value to the project will be recognized in our README.md file.

Thank you for contributing to ExPorterSDK! ๐Ÿš€