Class: TesoteSdk::V2::SyncSessions
- Inherits:
-
Object
- Object
- TesoteSdk::V2::SyncSessions
- Defined in:
- lib/tesote_sdk/v2/sync_sessions.rb
Instance Method Summary collapse
-
#each_page(account_id, query = {}, opts: {}, page_size: 50, &block) ⇒ Object
Walks pages via offset pagination; yields OffsetPage per call.
-
#get(account_id, session_id, opts: {}) ⇒ Object
GET /v2/accounts/id/sync_sessions/session_id.
-
#initialize(transport) ⇒ SyncSessions
constructor
A new instance of SyncSessions.
-
#list(account_id, query = {}, opts: {}) ⇒ Object
GET /v2/accounts/id/sync_sessions.
Constructor Details
#initialize(transport) ⇒ SyncSessions
Returns a new instance of SyncSessions.
4 5 6 |
# File 'lib/tesote_sdk/v2/sync_sessions.rb', line 4 def initialize(transport) @transport = transport end |
Instance Method Details
#each_page(account_id, query = {}, opts: {}, page_size: 50, &block) ⇒ Object
Walks pages via offset pagination; yields OffsetPage per call.
23 24 25 26 27 28 29 30 |
# File 'lib/tesote_sdk/v2/sync_sessions.rb', line 23 def each_page(account_id, query = {}, opts: {}, page_size: 50, &block) return enum_for(:each_page, account_id, query, opts: opts, page_size: page_size) unless block enum = Pagination::OffsetEnumerator.new(start_query: query, limit: page_size) do |q| list(account_id, q, opts: opts) end enum.each(&block) end |
#get(account_id, session_id, opts: {}) ⇒ Object
GET /v2/accounts/id/sync_sessions/session_id
33 34 35 36 37 38 39 |
# File 'lib/tesote_sdk/v2/sync_sessions.rb', line 33 def get(account_id, session_id, opts: {}) raise ArgumentError, 'account_id is required' if account_id.nil? || account_id.to_s.empty? raise ArgumentError, 'session_id is required' if session_id.nil? || session_id.to_s.empty? body = @transport.request('GET', "accounts/#{account_id}/sync_sessions/#{session_id}", opts: opts) Models::SyncSession.from_hash(body) end |
#list(account_id, query = {}, opts: {}) ⇒ Object
GET /v2/accounts/id/sync_sessions
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/tesote_sdk/v2/sync_sessions.rb', line 9 def list(account_id, query = {}, opts: {}) raise ArgumentError, 'account_id is required' if account_id.nil? || account_id.to_s.empty? body = @transport.request('GET', "accounts/#{account_id}/sync_sessions", query: query, opts: opts) items_raw = (body && body['sync_sessions']) || [] Models::OffsetPage.new( items: Models::SyncSession.from_array(items_raw), limit: body && body['limit'], offset: body && body['offset'], has_more: body && body['has_more'] ) end |