Class: Bulkippt::FakeService

Inherits:
Object
  • Object
show all
Defined in:
lib/bulkippt/fake_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username, token) ⇒ FakeService

Returns a new instance of FakeService.



10
11
12
13
14
# File 'lib/bulkippt/fake_service.rb', line 10

def initialize(username, token)
  @username = username
  @token = token
  @clips = Clips.new
end

Instance Attribute Details

#clipsObject (readonly)

Returns the value of attribute clips.



8
9
10
# File 'lib/bulkippt/fake_service.rb', line 8

def clips
  @clips
end

#tokenObject (readonly)

Returns the value of attribute token.



8
9
10
# File 'lib/bulkippt/fake_service.rb', line 8

def token
  @token
end

#usernameObject (readonly)

Returns the value of attribute username.



8
9
10
# File 'lib/bulkippt/fake_service.rb', line 8

def username
  @username
end

Instance Method Details

#accountObject



16
17
18
19
20
21
22
# File 'lib/bulkippt/fake_service.rb', line 16

def 
  if credentials_valid?(@username, @token) 
    {username: @username, token: @token}.to_json
  else 
    raise Kippt::APIError, "Can't find an user with this username and api_key"
  end
end

#credentials_valid?(username, token) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
27
# File 'lib/bulkippt/fake_service.rb', line 24

def credentials_valid?(username, token)
  return false if username != 'valid' && @token != 'valid'
  true
end