Class: PBShipping::Developer

Inherits:
ShippingApiResource show all
Defined in:
lib/pbshipping/developer.rb

Instance Method Summary collapse

Methods inherited from ApiObject

#[], #[]=, #add_accessors, #as_json, convert_to_api_object, #create_accessor, #each, #initialize, #inspect, #key?, #keys, #metaclass, #respond_to?, #to_hash, #to_json, #to_s, #update, #values

Constructor Details

This class inherits a constructor from PBShipping::ApiObject

Instance Method Details

#getMerchantBulkAccount(auth_obj, emailid) ⇒ Object

CLIENT LIBRARY SPECIFIC API: GET /developers/developerId/merchants/emails/emailId/ API signature: get/developers/…/merchants/emails/…

Query for merchant details using merchant’s email address if developer is operating in bulk mode



73
74
75
76
# File 'lib/pbshipping/developer.rb', line 73

def getMerchantBulkAccount(auth_obj, emailid)
  # use the same underlying REST call
  return self.registerMerchantIndividualAccount(auth_obj, emailid)
end

#getTransactionReport(auth_obj, params) ⇒ Object

MANAGING MERCHANTS API: GET /ledger/developers/developerId/transactions/reports API signature: get/ledger/developers/…/transactions/reports

Retrieve all transactions based on the given input parameters



108
109
110
111
112
113
114
115
116
117
118
# File 'lib/pbshipping/developer.rb', line 108

def getTransactionReport(auth_obj, params)
  if self.key?(:developerId) == false   
    raise MissingResourceAttribute.new(:developerId)
  end  
  api_sig = "get/ledger/developers/.../transactions/reports"
  api_version = PBShipping::get_api_version(api_sig)
  api_path = "/ledger/developers/" + self[:developerId]
  api_path += "/transactions/reports"
  ApiObject.new(PBShipping::api_request(
    auth_obj, :get, api_version, api_path, {}, params, {}))
end

#refresh(auth_obj) ⇒ Object

CLIENT LIBRARY SPECIFIC API: GET /developers/developerId API signature: get/developers/…

Query for developer account attributes



30
31
32
33
34
35
36
37
38
39
# File 'lib/pbshipping/developer.rb', line 30

def refresh(auth_obj)
  if self.key?(:developerId) == false
    raise MissingResourceAttribute.new(:developerId)
  end
  api_sig = "get/developers/.."
  api_version = PBShipping::get_api_version(api_sig)
  api_path = "/developers/" + self[:developerId]
  json_resp = PBShipping::api_request(auth_obj, :get, api_version, api_path, {}, {}, {})
  self.update(json_resp) 
end

#registerMerchantBulkAccount(auth_obj, address) ⇒ Object

MANAGING MERCHANTS API: POST /developers/developerId/merchants/registration API signature: post/developers/…/merchants/registration

Register your merchants or shippers, if you have signed up for the bulk account payment model.

This method allows you to retrieve the merchant ID and related information, so that you can request transactions on their behalf.



89
90
91
92
93
94
95
96
97
98
99
# File 'lib/pbshipping/developer.rb', line 89

def registerMerchantBulkAccount(auth_obj, address)
  if self.key?(:developerId) == false
    raise MissingResourceAttribute.new(:developerId)
  end
  api_sig = "post/developers/.../merchants/registration"
  api_version = PBShipping::get_api_version(api_sig)
  api_path = "/developers/" + self[:developerId]
  api_path += "/merchants/registration"
  Merchant.new(PBShipping::api_request(
    auth_obj, :post, api_version, api_path, {}, {}, address))
end

#registerMerchantIndividualAccount(auth_obj, emailid) ⇒ Object

MANAGING MERCHANTS API: GET /developers/developerId/merchants/emails/emailId/ API signature: get/developers/…/merchants/emails/…

Register your merchants or shippers, if you have signed up for the individual account payment model.

This method allows you to retrieve the merchant ID and related information based on the Email ID they used while registering, so that you can request transactions on their behalf.



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/pbshipping/developer.rb', line 53

def registerMerchantIndividualAccount(auth_obj, emailid)
  if self.key?(:developerId) == false
    raise MissingResourceAttribute.new(:developerId)
  end
  api_sig = "get/developers/.../merchants/emails/..."
  api_version = PBShipping::get_api_version(api_sig)
  api_path = "/developers/" + self[:developerId]
  api_path += "/merchants/emails/" + emailid + "/"
  Merchant.new(PBShipping::api_request(
    auth_obj, :get, api_version, api_path, {}, {}, {}))
end