Sha256: 1fc2407f06d9475220434ff837359637a71834bbd3bee33b262fc3b2e1f8b28b

Contents?: true

Size: 1.72 KB

Versions: 21

Compression:

Stored size: 1.72 KB

Contents

### Product Examples

If you are unfamiliar with fog, we recommend reading our [getting started](getting_started.md) guide.

#### Product Service

SoftLayer has Product Service that is used for complex ordering process, so we support getting information on packages and items.

All data available on the real api is available using the Fog.mock! so you can provide a real experience using mocks.

This is the first version of this service and our intention is to support more feature and allow reuse on the buying process.

#### Create a connection to SoftLayer Product Service

```ruby
	require 'fog/softlayer'
	@sl = Fog::Softlayer[:product]
```

#### Use the Models
1. List all packages

   ```ruby
   @sl.packages # list all packages
   ```

1. Get first package

   ```ruby
    pkg = @sl.packages.first
    # =>   <Fog::Softlayer::Product::Package
    #     id=0,
    #     description=nil,
    #     first_order_step_id=1,
    #     is_active=1,
    #     name="Additional Products",
    #     sub_description=nil,
    #     unit_size=0
    #   >
   ```

1. Get items for a package.

	```ruby
	items = @sl.packages.first.items		
	```
items will be a collection of Fog::Softlayer::Product::Item models.

1. Get a specific item

	```ruby
  @sl.packages.first.items.get(559)
    # =>   <Fog::Softlayer::Product::Item
    #     id=559,
    #     capacity=40.0,
    #     description="40GB EVault Disk to Disk Enterprise Backup",
    #     item_tax_category_id=166,
    #     key_name="EVAULT_40_GB",
    #     long_description=nil,
    #     software_description_id=159,
    #     units="GIGABYTE",
    #     upgrade_item_id=3784
	```

We need to make this nested call because we need package id on our items model, because items are related to packages.

Version data entries

21 entries across 19 versions & 3 rubygems

Version Path
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-softlayer-1.1.4/examples/product.md
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-softlayer-1.1.4/examples/product.md
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-softlayer-1.1.4/examples/product.md
fog-softlayer-1.1.4 examples/product.md
fog-softlayer-1.1.3 examples/product.md
fog-softlayer-1.1.2 examples/product.md
fog-softlayer-1.1.1 examples/product.md
fog-softlayer-1.1.0 examples/product.md
fog-softlayer-1.0.3 examples/product.md
fog-softlayer-1.0.2 examples/product.md
fog-softlayer-1.0.1 examples/product.md
fog-softlayer-1.0.0 examples/product.md
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-softlayer-0.4.7/examples/product.md
fog-softlayer-0.4.7 examples/product.md
fog-softlayer-0.4.6 examples/product.md
fog-softlayer-0.4.5 examples/product.md
fog-softlayer-0.4.4 examples/product.md
fog-softlayer-0.4.3 examples/product.md
fog-softlayer-0.4.2 examples/product.md
fog-softlayer-0.4.2.pre examples/product.md