Sha256: 1b4678681c97d1a857fdaf0ad95c50bc56032e65ceb9729c64d366891625c77d

Contents?: true

Size: 536 Bytes

Versions: 2

Compression:

Stored size: 536 Bytes

Contents

# frozen_string_literal: true

require 'ostruct'

module SPACEX
  module Launches
    ROOT_URI = 'https://api.spacexdata.com/v2'

    def self.latest
      path = 'launches/latest'

      data = Faraday.new(
        url: "#{ROOT_URI}/#{path}",
        request: {
          params_encoder: Faraday::FlatParamsEncoder
        }
      ) do |c|
        c.use ::FaradayMiddleware::ParseJson
        c.use Faraday::Response::RaiseError
        c.use Faraday::Adapter::NetHttp
      end
      Hashie::Mash.new(data.get.body)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spacex-0.0.4 lib/spacex/launches.rb
spacex-0.0.3 lib/spacex/launches.rb