Sha256: 98b9605ce8b1e9f39b228d25575b4ecc5eaf2ec09fa5e6874b7c625eaadd1b95

Contents?: true

Size: 976 Bytes

Versions: 17

Compression:

Stored size: 976 Bytes

Contents

require 'blurb/request_collection_with_campaign_type'

class Blurb
  class SnapshotRequests < RequestCollectionWithCampaignType
    def initialize(campaign_type:, base_url:, headers:)
      @campaign_type = campaign_type
      @base_url = "#{base_url}/v2/#{@campaign_type}"
      @headers = headers
    end

    def create(record_type, state_filter='enabled,paused')
      execute_request(
        api_path: "/#{record_type.to_s.camelize(:lower)}/snapshot",
        request_type: :post,
        payload: {state_filter: state_filter}
      )
    end

    def retrieve(snapshot_id)
      execute_request(
        api_path: "/snapshots/#{snapshot_id}",
        request_type: :get,
      )
    end

    def download(snapshot_id)
      download_url = retrieve(snapshot_id)[:location]
      headers = @headers.dup["Content-Encoding"] = "gzip"
      Request.new(
        url: download_url,
        request_type: :get,
        headers: @headers
      ).make_request
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
blurb-0.5.9 lib/blurb/snapshot_requests.rb
blurb-0.5.8 lib/blurb/snapshot_requests.rb
blurb-0.5.6 lib/blurb/snapshot_requests.rb
blurb-0.5.5 lib/blurb/snapshot_requests.rb
blurb-0.5.2 lib/blurb/snapshot_requests.rb
blurb-0.5.1 lib/blurb/snapshot_requests.rb
blurb-0.4.12 lib/blurb/snapshot_requests.rb
blurb-0.4.11 lib/blurb/snapshot_requests.rb
blurb-0.4.10 lib/blurb/snapshot_requests.rb
blurb-0.4.8 lib/blurb/snapshot_requests.rb
blurb-0.4.7 lib/blurb/snapshot_requests.rb
blurb-0.4.6 lib/blurb/snapshot_requests.rb
blurb-0.4.5 lib/blurb/snapshot_requests.rb
blurb-0.4.4 lib/blurb/snapshot_requests.rb
blurb-0.4.2 lib/blurb/snapshot_requests.rb
blurb-0.4.1 lib/blurb/snapshot_requests.rb
blurb-0.4.0 lib/blurb/snapshot_requests.rb