Module: Orderspace::Structs
- Included in:
- Endpoint::Customers, Endpoint::Oauth, Endpoint::Orders, Endpoint::Webhooks
- Defined in:
- lib/orderspace/structs.rb,
lib/orderspace/struct/buyer.rb,
lib/orderspace/struct/event.rb,
lib/orderspace/struct/order.rb,
lib/orderspace/struct/address.rb,
lib/orderspace/struct/webhook.rb,
lib/orderspace/struct/customer.rb,
lib/orderspace/struct/oauth_credentials.rb
Overview
mandatory company_name, login_email? contact_name, address (company name, contact name, line1, postcode country)
Defined Under Namespace
Classes: Address, Buyer, Customer, CustomerList, CustomerValidator, Event, OauthCredentials, Order, OrderLine, OrderList, Webhook, WebhookList
Class Method Summary collapse
-
.from(json, struct) ⇒ Struct
Converts (if possible) a json payload into the desired struct.
-
.hashify(struct) ⇒ Hash
Converts a struct into a hash.
-
.validate(struct) ⇒ Object
Used to make sure the struct is valid before it’s posted to the server.
Class Method Details
.from(json, struct) ⇒ Struct
Converts (if possible) a json payload into the desired struct
12 13 14 15 16 17 18 |
# File 'lib/orderspace/structs.rb', line 12 def self.from(json, struct) if json.is_a? Array json.collect {|element| assign_values_to_struct(element, struct)} else assign_values_to_struct(json, struct) end end |
.hashify(struct) ⇒ Hash
Converts a struct into a hash
24 25 26 |
# File 'lib/orderspace/structs.rb', line 24 def self.hashify(struct) hash_dump(struct) end |
.validate(struct) ⇒ Object
Used to make sure the struct is valid before it’s posted to the server
32 33 34 35 |
# File 'lib/orderspace/structs.rb', line 32 def self.validate(struct) validator = eval(struct.class.to_s + 'Validator') validator.validate(struct) end |