class RubyKong::Request::Consumer::Stub

Public Class Methods

create() click to toggle source
# File lib/ruby-kong/request/consumer.rb, line 118
def self.create
  url = RubyKong::Utils.endpoint_builder(RubyKong.paths[:consumer][:create])

  RubyKong::Stub.request(
    :method   => :post,
    :url      => url,
    :request  => {
      :body => {
        :username => 'lamdt'
      }
    },
    :response => {
      :status => 201,
      :body   => {
        'username'   => 'lamdt',
        'created_at' => 1458789832000,
        'id'         => 'b880f403-b161-4294-9a13-2462d39991b2'
      }.to_s
    }
  )
end
delete() click to toggle source
# File lib/ruby-kong/request/consumer.rb, line 35
def self.delete
  # Mock with /consumers/lamdt path
  path = RubyKong.paths[:consumer][:delete] + 'lamdt'
  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/consumer.rb, line 95
def self.list
  url = RubyKong::Utils.endpoint_builder(RubyKong.paths[:consumer][:list])

  RubyKong::Stub.request(
    :method   => :get,
    :url      => url,
    :response => {
      :status => 200,
      :body   => {
        "data"  =>
        [
          {
            'username'   => 'lamdt',
            'created_at' => 1458789832000,
            'id'         => 'b880f403-b161-4294-9a13-2462d39991b2'
          }
        ],
        "total" => 1
      }.to_s
    }
  )
end
retrieve() click to toggle source
# File lib/ruby-kong/request/consumer.rb, line 76
def self.retrieve
  # Mock with /consumers/lamdt path
  path = RubyKong.paths[:consumer][:retrieve] + 'lamdt'
  url = RubyKong::Utils.endpoint_builder(path)

  RubyKong::Stub.request(
    :method   => :get,
    :url      => url,
    :response => {
      :status => 200,
      :body   => {
        'username'   => 'lamdt',
        'created_at' => 1458789832000,
        'id'         => 'b880f403-b161-4294-9a13-2462d39991b2'
      }.to_s
    }
  )
end
update() click to toggle source
# File lib/ruby-kong/request/consumer.rb, line 50
def self.update
  # Mock with /consumers/lamdt path
  path = RubyKong.paths[:consumer][:update] + 'lamdt'
  url = RubyKong::Utils.endpoint_builder(path)

  RubyKong::Stub.request(
    :method   => :patch,
    :url      => url,
    :request  => {
      :body => {
        :custom_id => '1234',
        :username  => 'lamdt'
      }
    },
    :response => {
      :status => 200,
      :body   => {
        'custom_id'  => 1234,
        'username'   => 'lamdt',
        'created_at' => 1458789832000,
        'id'         => 'b880f403-b161-4294-9a13-2462d39991b2'
      }.to_s
    }
  )
end