Class: BranchIO::Client::BulkUrlsResponse

Inherits:
Response
  • Object
show all
Defined in:
lib/branch_io/client/response.rb

Defined Under Namespace

Classes: EmbeddedResponseWrapper

Instance Attribute Summary

Attributes inherited from Response

#response

Instance Method Summary collapse

Methods inherited from Response

#failure?, #initialize, #json, #request, #validate!

Constructor Details

This class inherits a constructor from BranchIO::Client::Response

Instance Method Details

#erroneous_responsesObject



80
81
82
# File 'lib/branch_io/client/response.rb', line 80

def erroneous_responses
  responses.reject(&:success?)
end

#errorsObject



72
73
74
# File 'lib/branch_io/client/response.rb', line 72

def errors
  erroneous_responses.map(&:error)
end

#responsesObject



84
85
86
87
88
89
90
91
92
93
# File 'lib/branch_io/client/response.rb', line 84

def responses
  @responses ||= json.map do |url_info|
    # below the EmbeddedResponseWrapper(s) act as a dummp HTTParty response
    if url_info.has_key?("error")
      ErrorResponse.new(EmbeddedResponseWrapper.new(url_info))
    else
      UrlResponse.new(EmbeddedResponseWrapper.new(url_info))
    end
  end
end

#success?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/branch_io/client/response.rb', line 64

def success?
  responses.all?(&:success?)
end

#successful_responsesObject



76
77
78
# File 'lib/branch_io/client/response.rb', line 76

def successful_responses
  responses.select(&:success?)
end

#urlsObject



68
69
70
# File 'lib/branch_io/client/response.rb', line 68

def urls
  successful_responses.map(&:url)
end