README.md in smartsend-ruby-0.0.2 vs README.md in smartsend-ruby-0.0.3
- old
+ new
@@ -8,13 +8,12 @@
```ruby
gem install 'smartsend-ruby'
```
-## Usage
-### Configuring the client
+## Configuration
```ruby
Smartsend.configure(
api_key: 'smartsend-api-key',
email: 'smartsend-username',
@@ -22,20 +21,22 @@
cms_system: 'Ruby on Rails',
cms_version: '5.0.0'
)
```
+## Usage
+
### Creating an order
This creates a label.
```ruby
-
# initalize a new order
order = Smartsend::Order.new(
+ id: "123123123", # your internal order id
order_number: "AC12345789",
- carrier: "postdanmark", # postdanmark/gls/bring
+ carrier: "postnord", # postnord/gls/bring
method: "private",
return: false,
total_price: 199.75,
shipping_price: 49,
currency: "DKK",
@@ -56,12 +57,13 @@
country: "DK",
phone: "12345678",
mail: "contact@smartsend.io"
)
-# set the receiver of the order
+# optionally set the sender of the order
order.sender = Smartsend::Sender.new(
+ id: "123456",
company: "Smart Send",
name1: "Henrik Hansen",
name2: "C/O Vivian Hansen",
address1: "Willemoesgade 42",
address2: "3.th.",
@@ -70,13 +72,13 @@
country: "DK",
phone: "12345678",
mail: "contact@smartsend.io"
)
-# you can ship to a droppoint by seting an agent
+# optionally ship to a droppoint by setting an agent
order.agent = Smartsend::Agent.new(
- id: "7224", # droppoint id
+ id: "2103", # droppoint id
type: "PDK", # droppoint provider
company: "Smart Send",
name1: "Henrik Hansen",
name2: "C/O Vivian Hansen",
address1: "Willemoesgade 42",
@@ -112,41 +114,61 @@
unit_weight: 1.25,
unit_price: 144.5,
currency: "DKK"
)
-parcel.items = [parcel_item]
-order.parcels = [parcel]
+parcel.items << parcel_item
+order.parcels << parcel
# send the order to Smartsend.io
order.save!
```
-After saving an order it is updated with a url for the label pdf and tracking codes for each parcel.
+After saving, the order it is updated with a url for the label pdf and tracking codes for each parcel.
```ruby
order.label_url
- => 'https://www.pacsoftonline.com/...'
+ => 'http://v70.api.smartsend.dk/...'
order.parcels.first.tracking_code
=> '1234...'
order.parcels.first.tracking_url
- => 'https://...'
+ => 'https://tracking.postnord.com/...'
```
### Creating orders in batch
You can create up to 10 orders in batch.
+This updates all orders with a label_url and also gives you a labels_url with the combined labels
+
```ruby
-order1 = Smartsend::Order.new(...)
-order2 = Smartsend::Order.new(...)
-orders = Smartsend::Orders.new(order1, order2)
+orders = Smartsend::Orders.new
+orders << Smartsend::Order.new(...)
+orders << Smartsend::Order.new(...)
# send the orders to Smartsend.io
orders.save_all!
+orders.labels_url
+ => 'http://v70.api.smartsend.dk/...'
+
orders.first.label_url
- => 'https://www.pacsoftonline.com/...'
+ => 'http://v70.api.smartsend.dk/...'
+```
+
+### Using multiple accounts
+
+If your system requires multiple accounts you can pass an account instance when saving orders.
+
+```ruby
+order = Smartsend::Order.new(...)
+
+account = Smartsend::Account.new(
+ email: 'smartsend-username',
+ license: 'smartsend-license-key'
+)
+
+order.save!(account: account)
```