Class: Bugcrowd::Client

Inherits:
Object
  • Object
show all
Includes:
Bounties
Defined in:
lib/bugcrowd/client.rb,
lib/bugcrowd/client/bounties.rb

Defined Under Namespace

Modules: Bounties

Constant Summary collapse

API_ENDPOINT =
"https://api.bugcrowd.com".freeze
USER_AGENT =
"Bugcrowd Ruby Gem #{Bugcrowd::VERSION}".freeze
MEDIA_TYPE =
"application/vnd.bugcrowd+json"

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Bounties

#list_bounties

Constructor Details

#initialize(username: ENV['BUGCROWD_USER'], password: ENV['BUGCROWD_PASSWORD']) ⇒ Client

Returns a new instance of Client.



14
15
16
17
# File 'lib/bugcrowd/client.rb', line 14

def initialize(username: ENV['BUGCROWD_USER'], password: ENV['BUGCROWD_PASSWORD'])
  self.username = username
  self.password = password
end

Instance Attribute Details

#passwordObject

Returns the value of attribute password.



12
13
14
# File 'lib/bugcrowd/client.rb', line 12

def password
  @password
end

#usernameObject

Returns the value of attribute username.



12
13
14
# File 'lib/bugcrowd/client.rb', line 12

def username
  @username
end

Instance Method Details

#connectionObject



44
45
46
# File 'lib/bugcrowd/client.rb', line 44

def connection
  @connection = Excon.new(API_ENDPOINT, connection_options)
end

#connection_optionsObject



33
34
35
36
37
38
39
40
41
42
# File 'lib/bugcrowd/client.rb', line 33

def connection_options
  {
    headers: {
      "Accept" => MEDIA_TYPE,
      "User-Agent" => USER_AGENT
    },
    user: self.username,
    password: self.password
  }
end

#get(path, options = {}) ⇒ Object



28
29
30
31
# File 'lib/bugcrowd/client.rb', line 28

def get(path, options = {})
  options.merge!(path: path)
  connection.get(options)
end

#inspectObject



19
20
21
22
23
24
25
26
# File 'lib/bugcrowd/client.rb', line 19

def inspect
  inspected = super

  inspected = inspected.gsub! self.username, "*******" if self.username
  inspected = inspected.gsub! self.password, "*******" if self.password

  inspected
end