Class: Restforce::DB::Client
- Inherits:
-
Restforce::Data::Client
- Object
- Restforce::Data::Client
- Restforce::DB::Client
- Defined in:
- lib/restforce/db/client.rb
Overview
Restforce::DB::Client is a thin abstraction on top of the default Restforce::Data::Client class, which adds support for an API endpoint not yet supported by the base gem.
Instance Method Summary collapse
-
#get_deleted_between(sobject, start_time, end_time = Time.now) ⇒ Object
Public: Get a list of Salesforce records which have been deleted between the specified times.
-
#initialize(**_) ⇒ Client
constructor
Public: Instantiate a new Restforce::DB::Client.
Constructor Details
#initialize(**_) ⇒ Client
Public: Instantiate a new Restforce::DB::Client. Updates the middleware stack to account for some additional instrumentation and automatically retry timed out requests.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/restforce/db/client.rb', line 13 def initialize(**_) super # NOTE: By default, the Retry middleware will catch timeout exceptions, # and retry up to two times. For more information, see: # https://github.com/lostisland/faraday/blob/master/lib/faraday/request/retry.rb middleware.insert( -2, Faraday::Request::Retry, methods: [:get, :head, :options, :put, :patch, :delete], ) middleware.insert_after( Restforce::Middleware::InstanceURL, FaradayMiddleware::Instrumentation, name: "request.restforce_db", ) middleware.insert_before( FaradayMiddleware::Instrumentation, Restforce::DB::Middleware::StoreRequestBody, ) end |
Instance Method Details
#get_deleted_between(sobject, start_time, end_time = Time.now) ⇒ Object
Public: Get a list of Salesforce records which have been deleted between the specified times.
sobject - The Salesforce object type to query against. start_time - A Time or Time-compatible object indicating the earliest
time for which to find deleted records.
end_time - A Time or Time-compatible object indicating the latest time
for which to find deleted records. Defaults to the current
time.
Example
Restforce::DB.client.get_deleted_between(
"CustomObject__c",
Time.now - 300,
Time.now,
)
#=> [
#<Restforce::Mash
deletedDate="2015-05-18T22:31:17.000+0000"
id="a001a000001a5vOAAQ"
>,
]
Returns an Array of Restforce::Mash objects.
63 64 65 66 67 68 69 70 71 |
# File 'lib/restforce/db/client.rb', line 63 def get_deleted_between(sobject, start_time, end_time = Time.now) response = api_get( "sobjects/#{sobject}/deleted", start: start_time.utc.iso8601, end: end_time.utc.iso8601, ) Array(response.body["deletedRecords"]) end |