class RubyKong::Request::Api::Stub

Public Class Methods

create() click to toggle source
# File lib/ruby-kong/request/api.rb, line 123
def self.create
  url = RubyKong::Utils.endpoint_builder(RubyKong.paths[:api][:create])
  RubyKong::Stub.request(
    :method   => :post,
    :url      => url,
    :request  => {
      :body => {
        :upstream_url => 'https://api.shipit.vn/v1/',
        :request_host => 'api.shipit.vn',
        :name         => 'shipit'
      }
    },
    :response => {
      :status => 201,
      :body   => {
        'upstream_url' => 'https://api.shipit.vn/v1/',
        'id'           => '0faeb3a7-3839-4739-916a-6b139c5b491b',
        'name'         => 'shipit',
        'created_at'   => 1458706997000,
        'request_host' => 'api.shipit.vn'
      }.to_s
    }
  )
end
delete() click to toggle source
# File lib/ruby-kong/request/api.rb, line 35
def self.delete
  # Mock with /apis/shipit path
  path = RubyKong.paths[:api][:delete] + 'shipit'
  url  = RubyKong::Utils.endpoint_builder(path)

  RubyKong::Stub.request(
    :method   => :delete,
    :url      => url,
    :response => {
      :status => 204,
      :body   => ""
    }
  )
end
list() click to toggle source
# File lib/ruby-kong/request/api.rb, line 98
def self.list
  url = RubyKong::Utils.endpoint_builder(RubyKong.paths[:api][:list])

  RubyKong::Stub.request(
    :method   => :get,
    :url      => url,
    :response => {
      :status => 200,
      :body   => {
        "data"  =>
        [
          {
            "upstream_url" => "https://api.shipit.vn/v1/",
            "id"           => "0faeb3a7-3839-4739-916a-6b139c5b491b",
            "name"         => "shipit",
            "created_at"   => 1458706997000,
            "request_host" => "api.shipit.vn"
          }
        ],
        "total" => 1
      }.to_s
    }
  )
end
retrieve() click to toggle source
# File lib/ruby-kong/request/api.rb, line 77
def self.retrieve
  # Mock with /apis/shipit path
  path = RubyKong.paths[:api][:retrieve] + 'shipit'
  url = RubyKong::Utils.endpoint_builder(path)

  RubyKong::Stub.request(
    :method   => :get,
    :url      => url,
    :response => {
      :status => 200,
      :body   => {
        "upstream_url" => "https://api.shipit.vn/v1/",
        "id"           => "0faeb3a7-3839-4739-916a-6b139c5b491b",
        "name"         => "shipit",
        "created_at"   => 1458706997000,
        "request_host" => "api.shipit.vn"
      }.to_s
    }
  )
end
update() click to toggle source
# File lib/ruby-kong/request/api.rb, line 50
def self.update
  # Mock with /apis/shipit path
  path = RubyKong.paths[:api][:update] + 'shipit'
  url  = RubyKong::Utils.endpoint_builder(path)

  RubyKong::Stub.request(
    :method   => :patch,
    :url      => url,
    :request  => {
      :body => {
        :upstream_url => 'https://api.shipit.vn/v2/',
        :name         => 'shipit'
      }
    },
    :response => {
      :status => 200,
      :body   => {
        'upstream_url' => 'https://api.shipit.vn/v2/',
        'id'           => '0faeb3a7-3839-4739-916a-6b139c5b491b',
        'name'         => 'shipit',
        'created_at'   => 1458706997000,
        'request_host' => 'api.shipit.vn'
      }.to_s
    }
  )
end