Class: IletimerkeziSdk::Responses::SummaryResponse

Inherits:
BaseResponse
  • Object
show all
Includes:
Enumerable
Defined in:
lib/iletimerkezi_sdk/responses/summary_response.rb

Instance Attribute Summary

Attributes inherited from BaseResponse

#data, #message, #status_code

Instance Method Summary collapse

Methods inherited from BaseResponse

#get_data, #get_message, #get_status_code, #ok?

Constructor Details

#initialize(response_body, http_status_code, page) ⇒ SummaryResponse

Returns a new instance of SummaryResponse.



6
7
8
9
10
# File 'lib/iletimerkezi_sdk/responses/summary_response.rb', line 6

def initialize(response_body, http_status_code, page)
  @orders = []
  @current_page = page
  super(response_body, http_status_code)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class IletimerkeziSdk::Responses::BaseResponse

Instance Method Details

#countObject



20
21
22
# File 'lib/iletimerkezi_sdk/responses/summary_response.rb', line 20

def count
  @data.dig('count') || 0
end

#current_pageObject



28
29
30
# File 'lib/iletimerkezi_sdk/responses/summary_response.rb', line 28

def current_page
  @current_page
end

#each(&block) ⇒ Object



12
13
14
# File 'lib/iletimerkezi_sdk/responses/summary_response.rb', line 12

def each(&block)
  @orders.each(&block)
end

#has_more_pages?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/iletimerkezi_sdk/responses/summary_response.rb', line 32

def has_more_pages?
  @current_page < total_pages
end

#ordersObject



16
17
18
# File 'lib/iletimerkezi_sdk/responses/summary_response.rb', line 16

def orders
  @orders
end

#total_pagesObject



24
25
26
# File 'lib/iletimerkezi_sdk/responses/summary_response.rb', line 24

def total_pages
  (count / 30).ceil
end