@@ -44,7 +44,7 @@ def self.clear_describe_cache!
4444 @objects_meta_cache = nil
4545 end
4646
47- # @!group Accessor methods
47+ # @!group "Objects" Methods
4848
4949 # Retrieve a single object of the specified type.
5050 #
@@ -74,8 +74,20 @@ def self.get_objects object_type, params={}
7474 objects_call :get , object_type , endpoint : '/objects' , data : params
7575 end
7676
77- # @!endgroup
78- # @!group Modifier methods
77+ # Create an object with the given data
78+ #
79+ # @example
80+ # Ontraport.create :contact, { email: '[email protected] ', firstname: 'Foo' } 81+ # #=> #<Ontraport::Response @data=...>
82+ #
83+ # @see https://api.ontraport.com/doc/#!/objects/createObject API docs
84+ #
85+ # @param object_type [Symbol] the type of object
86+ # @param params [Hash] input data
87+ # @return [Response]
88+ def self . create object_type , params
89+ objects_call :post , object_type , endpoint : '/objects' , data : params
90+ end
7991
8092 # Create an object with the given data, or merge if the unique field matches another row.
8193 #
@@ -139,6 +151,19 @@ def self.untag_objects object_type, object:, tag:
139151 objects_call :delete , object_type , endpoint : '/objects/tag' , data : params
140152 end
141153
154+ # @!endgroup
155+ # @!group "Transactions" Methods
156+
157+ # Get full information about an order
158+ #
159+ # @see https://api.ontraport.com/doc/#!/transactions/getOrder API docs
160+ #
161+ # @param order_id [Integer] Id of the order
162+ # @return [Response]
163+ def self . get_order order_id
164+ request_with_authentication :get , endpoint : '/transaction/order' , data : { id : order_id }
165+ end
166+
142167 # @!endgroup
143168
144169 private
@@ -154,7 +179,8 @@ def self.request_with_authentication method, endpoint:, data: nil
154179 response = HTTParty . send *args , **kwargs
155180
156181 unless response . code . eql? 200
157- raise APIError . new response . body
182+ error = "#{ response . code } #{ response . msg } "
183+ raise APIError . new ( response . body . present? ? "#{ error } - #{ response . body } " : error )
158184 end
159185
160186 Response . new **response . parsed_response . symbolize_keys
0 commit comments