Class: Xdelivery::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/xdelivery/client.rb,
lib/xdelivery/exceptions.rb

Defined Under Namespace

Classes: UnknownResponse

Constant Summary collapse

EXPECTED_STATUSES =
{
  200 => 'Ok' ,
  401 => 'Unauthorized'
}
EXCEPTION_STATUSES =
{
  404 => 'Not Found',
  500 => 'Internal Server Error',
  502 => 'Bad Gateway',
  503 => 'Service Unavailable',
  504 => 'Gateway Timeout',
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(merchant_no, access_key) ⇒ Client

Returns a new instance of Client.



6
7
8
9
# File 'lib/xdelivery/client.rb', line 6

def initialize(merchant_no, access_key)
  self.merchant_no = merchant_no
  self.access_key = access_key
end

Instance Attribute Details

#access_keyObject

Returns the value of attribute access_key.



4
5
6
# File 'lib/xdelivery/client.rb', line 4

def access_key
  @access_key
end

#merchant_noObject

Returns the value of attribute merchant_no.



4
5
6
# File 'lib/xdelivery/client.rb', line 4

def merchant_no
  @merchant_no
end

Instance Method Details

#create_orders! {|api| ... } ⇒ Object

Yields:

  • (api)


11
12
13
14
15
# File 'lib/xdelivery/client.rb', line 11

def create_orders!
  api = API::Orders.new(merchant_no, access_key)
  yield(api)
  api.create!
end

#create_sales! {|api| ... } ⇒ Object

Yields:

  • (api)


17
18
19
20
21
# File 'lib/xdelivery/client.rb', line 17

def create_sales!
  api = API::Sales.new(merchant_no, access_key)
  yield(api)
  api.create!
end

#get_shops!Object



29
30
31
# File 'lib/xdelivery/client.rb', line 29

def get_shops!
  API::Shops.new(merchant_no, access_key).get!
end

#ping!Object



33
34
35
36
# File 'lib/xdelivery/client.rb', line 33

def ping!
  api = API::Ping.new(merchant_no, access_key)
  api.ping!
end

#update_products! {|api| ... } ⇒ Object

Yields:

  • (api)


23
24
25
26
27
# File 'lib/xdelivery/client.rb', line 23

def update_products!
  api = API::Products.new(merchant_no, access_key)
  yield(api)
  api.update!
end