Sha256: 1c3bd0feaa149d498122225220031aa56892a1c42de616a16598e3479fad06fe

Contents?: true

Size: 1.37 KB

Versions: 31

Compression:

Stored size: 1.37 KB

Contents

class Ey::Core::Client
  class Real
    def create_address(params={})
      request(
        :method => :post,
        :path   => "/addresses",
        :params => params,
      )
    end
  end # Real

  class Mock
    def create_address(params={})
      request_id  = self.uuid
      resource_id = self.serial_id
      provider_id = params["provider"]

      self.find(:providers, provider_id)

      resource = params["address"].dup
      ip_address = resource["provisioned_id"] || self.ip_address
      resource.merge!(
        "id"             => resource_id,
        "provisioned_id" => ip_address,
        "ip_address"     => ip_address,
        "resource_url"   => "/addresses/#{resource_id}",
        "provider"       => url_for("/providers/#{provider_id}")
      )

      request = {
        "id"          => request_id,
        "type"        => "provision_address",
        "successful"  => "true",
        "started_at"  => Time.now,
        "finished_at" => nil,
        "resource"    => [:addresses, resource_id, resource],
      }

      self.data[:requests][request_id] = request

      response_hash = request.dup
      response_hash.delete("resource")

      response(
        :body    => {"request" => response_hash},
        :status  => 201,
        :headers => {
          "Content-Type" => "application/json; charset=utf8"
        }
      )
    end
  end # Mock
end # Ey::Core::Client

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
ey-core-3.4.4 lib/ey-core/requests/create_address.rb
ey-core-3.4.2 lib/ey-core/requests/create_address.rb
ey-core-3.4.1 lib/ey-core/requests/create_address.rb
ey-core-3.4.0 lib/ey-core/requests/create_address.rb
ey-core-3.3.1 lib/ey-core/requests/create_address.rb
ey-core-3.3.0 lib/ey-core/requests/create_address.rb
ey-core-3.2.6 lib/ey-core/requests/create_address.rb
ey-core-3.2.5 lib/ey-core/requests/create_address.rb
ey-core-3.2.4 lib/ey-core/requests/create_address.rb
ey-core-3.2.3 lib/ey-core/requests/create_address.rb
ey-core-3.2.2 lib/ey-core/requests/create_address.rb
ey-core-3.2.1 lib/ey-core/requests/create_address.rb
ey-core-3.2.0 lib/ey-core/requests/create_address.rb
ey-core-3.1.11 lib/ey-core/requests/create_address.rb
ey-core-3.1.10 lib/ey-core/requests/create_address.rb
ey-core-3.1.9 lib/ey-core/requests/create_address.rb
ey-core-3.1.8 lib/ey-core/requests/create_address.rb
ey-core-3.1.7 lib/ey-core/requests/create_address.rb
ey-core-3.1.6 lib/ey-core/requests/create_address.rb
ey-core-3.1.5 lib/ey-core/requests/create_address.rb