Class: Access::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/access/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

Returns a new instance of Response.



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/access/response.rb', line 27

def initialize(response)
  @response = response # Setting this temporarily so i can have a working member reg call, since it doesn't follow the resource [] best practices
  response.each { |key, value| instance_variable_set("@#{key}", value) if self.class.instance_methods.include? key.to_sym }
  @response_status = response.message
  @status ||= response.code
  check_success(response)
  if @success
    @info = Access::Info.new(@info) if @info
    (@links = @links.is_a?(Array) ? Access::Link.process_batch(@links) : Access::Link.new(@links)) if @links
    process_data
  end
end

Instance Attribute Details

#access_tokensObject (readonly)

resources



7
8
9
# File 'lib/access/response.rb', line 7

def access_tokens
  @access_tokens
end

#aggregationsObject (readonly)

hotel



25
26
27
# File 'lib/access/response.rb', line 25

def aggregations
  @aggregations
end

#api_calls_over_timeObject (readonly)

usages



13
14
15
# File 'lib/access/response.rb', line 13

def api_calls_over_time
  @api_calls_over_time
end

#campaign_descriptionObject (readonly)

campaign show page



15
16
17
# File 'lib/access/response.rb', line 15

def campaign_description
  @campaign_description
end

#campaign_nameObject (readonly)

campaign show page



15
16
17
# File 'lib/access/response.rb', line 15

def campaign_name
  @campaign_name
end

#campaign_rankingObject (readonly)

campaign show page



15
16
17
# File 'lib/access/response.rb', line 15

def campaign_ranking
  @campaign_ranking
end

#campaignsObject (readonly)

resources



7
8
9
# File 'lib/access/response.rb', line 7

def campaigns
  @campaigns
end

#categoriesObject (readonly)

resources



7
8
9
# File 'lib/access/response.rb', line 7

def categories
  @categories
end

#channel_descriptionObject (readonly)

channel show page



19
20
21
# File 'lib/access/response.rb', line 19

def channel_description
  @channel_description
end

#channel_identifierObject (readonly)

channel show page



19
20
21
# File 'lib/access/response.rb', line 19

def channel_identifier
  @channel_identifier
end

#channel_listObject (readonly)

campaign show page



15
16
17
# File 'lib/access/response.rb', line 15

def channel_list
  @channel_list
end

#channel_nameObject (readonly)

channel show page



19
20
21
# File 'lib/access/response.rb', line 19

def channel_name
  @channel_name
end

#channel_typeObject (readonly)

channel show page



19
20
21
# File 'lib/access/response.rb', line 19

def channel_type
  @channel_type
end

#channelsObject (readonly)

resources



7
8
9
# File 'lib/access/response.rb', line 7

def channels
  @channels
end

#content_typeObject (readonly)

redemptions



11
12
13
# File 'lib/access/response.rb', line 11

def content_type
  @content_type
end

#custom_aggregationObject (readonly)

aggregations



9
10
11
# File 'lib/access/response.rb', line 9

def custom_aggregation
  @custom_aggregation
end

#dataObject (readonly)

amt



23
24
25
# File 'lib/access/response.rb', line 23

def data
  @data
end

#detailsObject (readonly)

redemptions



11
12
13
# File 'lib/access/response.rb', line 11

def details
  @details
end

#dev_nodeObject (readonly)

basics



5
6
7
# File 'lib/access/response.rb', line 5

def dev_node
  @dev_node
end

#devicesObject (readonly)

resources



7
8
9
# File 'lib/access/response.rb', line 7

def devices
  @devices
end

#end_dateObject (readonly)

campaign show page



15
16
17
# File 'lib/access/response.rb', line 15

def end_date
  @end_date
end

#errorObject (readonly)

basics



5
6
7
# File 'lib/access/response.rb', line 5

def error
  @error
end

#favoritesObject (readonly)

resources



7
8
9
# File 'lib/access/response.rb', line 7

def favorites
  @favorites
end

#filtersObject (readonly)

resources



7
8
9
# File 'lib/access/response.rb', line 7

def filters
  @filters
end

#hotelsObject (readonly)

hotel



25
26
27
# File 'lib/access/response.rb', line 25

def hotels
  @hotels
end

#infoObject (readonly)

basics



5
6
7
# File 'lib/access/response.rb', line 5

def info
  @info
end

#internal_detailsObject (readonly)

basics



5
6
7
# File 'lib/access/response.rb', line 5

def internal_details
  @internal_details
end

#keyObject (readonly)

campaign show page



15
16
17
# File 'lib/access/response.rb', line 15

def key
  @key
end

basics



5
6
7
# File 'lib/access/response.rb', line 5

def links
  @links
end

#locationsObject (readonly)

resources



7
8
9
# File 'lib/access/response.rb', line 7

def locations
  @locations
end

#member_usageObject (readonly)

usages



13
14
15
# File 'lib/access/response.rb', line 13

def member_usage
  @member_usage
end

#membersObject (readonly)

resources



7
8
9
# File 'lib/access/response.rb', line 7

def members
  @members
end

#messageObject (readonly)

basics



5
6
7
# File 'lib/access/response.rb', line 5

def message
  @message
end

#oauth_access_tokenObject (readonly)

resources



7
8
9
# File 'lib/access/response.rb', line 7

def oauth_access_token
  @oauth_access_token
end

#oauth_applicationsObject (readonly)

resources



7
8
9
# File 'lib/access/response.rb', line 7

def oauth_applications
  @oauth_applications
end

#oauth_tokenObject (readonly)

resources



7
8
9
# File 'lib/access/response.rb', line 7

def oauth_token
  @oauth_token
end

#oauth_tokensObject (readonly)

resources



7
8
9
# File 'lib/access/response.rb', line 7

def oauth_tokens
  @oauth_tokens
end

#offer_count_by_facetObject (readonly)

aggregations



9
10
11
# File 'lib/access/response.rb', line 9

def offer_count_by_facet
  @offer_count_by_facet
end

#offer_count_by_redemption_methodObject (readonly)

aggregations



9
10
11
# File 'lib/access/response.rb', line 9

def offer_count_by_redemption_method
  @offer_count_by_redemption_method
end

#offer_count_in_categoriesObject (readonly)

aggregations



9
10
11
# File 'lib/access/response.rb', line 9

def offer_count_in_categories
  @offer_count_in_categories
end

#offer_redemptionsObject (readonly)

resources



7
8
9
# File 'lib/access/response.rb', line 7

def offer_redemptions
  @offer_redemptions
end

#offer_resourceObject (readonly)

spot show page



17
18
19
# File 'lib/access/response.rb', line 17

def offer_resource
  @offer_resource
end

#offersObject (readonly)

resources



7
8
9
# File 'lib/access/response.rb', line 7

def offers
  @offers
end

#product_groupsObject (readonly)

resources



7
8
9
# File 'lib/access/response.rb', line 7

def product_groups
  @product_groups
end

#productsObject (readonly)

resources



7
8
9
# File 'lib/access/response.rb', line 7

def products
  @products
end

#programsObject (readonly)

resources



7
8
9
# File 'lib/access/response.rb', line 7

def programs
  @programs
end

#redemption_methodObject (readonly)

redemptions



11
12
13
# File 'lib/access/response.rb', line 11

def redemption_method
  @redemption_method
end

#reportsObject (readonly)

resources



7
8
9
# File 'lib/access/response.rb', line 7

def reports
  @reports
end

#responseObject (readonly)

basics



5
6
7
# File 'lib/access/response.rb', line 5

def response
  @response
end

#response_statusObject (readonly)

basics



5
6
7
# File 'lib/access/response.rb', line 5

def response_status
  @response_status
end

#spot_image_urlObject (readonly)

spot show page



17
18
19
# File 'lib/access/response.rb', line 17

def spot_image_url
  @spot_image_url
end

#spot_listObject (readonly)

campaign show page



15
16
17
# File 'lib/access/response.rb', line 15

def spot_list
  @spot_list
end

#spot_nameObject (readonly)

spot show page



17
18
19
# File 'lib/access/response.rb', line 17

def spot_name
  @spot_name
end

#spot_rankingObject (readonly)

spot show page



17
18
19
# File 'lib/access/response.rb', line 17

def spot_ranking
  @spot_ranking
end

#spot_redirect_typeObject (readonly)

spot show page



17
18
19
# File 'lib/access/response.rb', line 17

def spot_redirect_type
  @spot_redirect_type
end

#spot_redirect_urlObject (readonly)

spot show page



17
18
19
# File 'lib/access/response.rb', line 17

def spot_redirect_url
  @spot_redirect_url
end

#spot_textObject (readonly)

spot show page



17
18
19
# File 'lib/access/response.rb', line 17

def spot_text
  @spot_text
end

#spotsObject (readonly)

resources



7
8
9
# File 'lib/access/response.rb', line 7

def spots
  @spots
end

#start_dateObject (readonly)

campaign show page



15
16
17
# File 'lib/access/response.rb', line 15

def start_date
  @start_date
end

#statusObject (readonly)

basics



5
6
7
# File 'lib/access/response.rb', line 5

def status
  @status
end

#storesObject (readonly)

resources



7
8
9
# File 'lib/access/response.rb', line 7

def stores
  @stores
end

#successObject (readonly)

basics



5
6
7
# File 'lib/access/response.rb', line 5

def success
  @success
end

#suggestionsObject (readonly)

resources



7
8
9
# File 'lib/access/response.rb', line 7

def suggestions
  @suggestions
end

#total_cart_countObject (readonly)

shopping cart count



21
22
23
# File 'lib/access/response.rb', line 21

def total_cart_count
  @total_cart_count
end

#usersObject (readonly)

resources



7
8
9
# File 'lib/access/response.rb', line 7

def users
  @users
end

#verifyObject (readonly)

resources



7
8
9
# File 'lib/access/response.rb', line 7

def verify
  @verify
end

Instance Method Details

#check_success(response) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/access/response.rb', line 40

def check_success(response)
  if response.success?
    @success = true
  else
    create_error
  end
end

#create_errorObject



48
49
50
51
52
# File 'lib/access/response.rb', line 48

def create_error
  @success = false
  @error = Access::Error.new(@response_status, @status, @message)
  remove_instance_variable(:@message) if @message
end