Sha256: 37f6e031481b2480da6833f40687b1e1b639be0eaa0d73fb1a0b6687738fe45b

Contents?: true

Size: 1.34 KB

Versions: 15

Compression:

Stored size: 1.34 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 = 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

15 entries across 15 versions & 1 rubygems

Version Path
ey-pro-cli-0.0.17 lib/vendor/core/ey-core/requests/create_address.rb
ey-pro-cli-0.0.16 lib/vendor/core/ey-core/requests/create_address.rb
ey-pro-cli-0.0.15 lib/vendor/core/ey-core/requests/create_address.rb
ey-pro-cli-0.0.14 lib/vendor/core/ey-core/requests/create_address.rb
ey-pro-cli-0.0.13 lib/vendor/core/ey-core/requests/create_address.rb
ey-pro-cli-0.0.12 lib/vendor/core/ey-core/requests/create_address.rb
ey-pro-cli-0.0.11 lib/vendor/core/ey-core/requests/create_address.rb
ey-pro-cli-0.0.10 lib/vendor/core/ey-core/requests/create_address.rb
ey-pro-cli-0.0.9 lib/vendor/core/ey-core/requests/create_address.rb
ey-pro-cli-0.0.8 lib/vendor/core/ey-core/requests/create_address.rb
ey-pro-cli-0.0.7 lib/vendor/core/ey-core/requests/create_address.rb
ey-pro-cli-0.0.6 lib/vendor/core/ey-core/requests/create_address.rb
ey-pro-cli-0.0.5 lib/vendor/core/ey-core/requests/create_address.rb
ey-pro-cli-0.0.4 lib/vendor/core/ey-core/requests/create_address.rb
ey-pro-cli-0.0.3 lib/vendor/core/ey-core/requests/create_address.rb