mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
38 lines
632 B
Ruby
38 lines
632 B
Ruby
![]() |
require 'fog/collection'
|
||
|
require 'fog/bluebox/models/product'
|
||
|
|
||
|
module Fog
|
||
|
module Bluebox
|
||
|
|
||
|
class Mock
|
||
|
def products
|
||
|
Fog::Bluebox::Products.new(:connection => self)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
class Real
|
||
|
def products
|
||
|
Fog::Bluebox::Products.new(:connection => self)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
class Products < Fog::Collection
|
||
|
|
||
|
model Fog::Bluebox::Product
|
||
|
|
||
|
def all
|
||
|
data = connection.get_products.body['products']
|
||
|
load(data)
|
||
|
end
|
||
|
|
||
|
def get(product_id)
|
||
|
connection.get_product(product_id)
|
||
|
rescue Excon::Errors::Forbidden
|
||
|
nil
|
||
|
end
|
||
|
|
||
|
end
|
||
|
|
||
|
end
|
||
|
end
|