Skip to content
This repository was archived by the owner on Jun 20, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/egnyte.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@
require "egnyte/permission"

module Egnyte
EGNYTE_DOMAIN = "egnyte.com"
end
2 changes: 1 addition & 1 deletion lib/egnyte/item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def fs_path(mode='fs')
end

def self.fs_path(session, mode='fs')
"https://#{session.domain}.#{EGNYTE_DOMAIN}/#{session.api}/v1/#{mode}/"
"https://#{session.domain}/#{session.api}/v1/#{mode}/"
end

def move_or_copy(destination_path, action)
Expand Down
2 changes: 1 addition & 1 deletion lib/egnyte/link.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def link_path
end

def self.link_path(session)
"https://#{session.domain}.#{EGNYTE_DOMAIN}/#{session.api}/v1/links"
"https://#{session.domain}/#{session.api}/v1/links"
end

end
Expand Down
2 changes: 1 addition & 1 deletion lib/egnyte/permission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def self.original_permissions(session, path, params=nil)
end

def self.permission_path(session)
"https://#{session.domain}.#{EGNYTE_DOMAIN}/#{session.api}/v1/perms/folder"
"https://#{session.domain}/#{session.api}/v1/perms/folder"
end

def valid?
Expand Down
12 changes: 9 additions & 3 deletions lib/egnyte/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@ def initialize(opts, strategy=:implicit, backoff=0.5)
@api = 'pubapi' # currently we only support the public API.

# the domain of the egnyte account to interact with.
raise Egnyte::DomainRequired unless @domain = opts[:domain]
raise Egnyte::DomainRequired unless opts_domain = opts[:domain]

if opts_domain =~ /.*\..*/
@domain = opts[:domain]
else
@domain = "#{opts_domain}.egnyte.com"
end

@client = OAuth2::Client.new(opts[:key], nil, {
:site => "https://#{@domain}.#{EGNYTE_DOMAIN}",
:site => "https://#{@domain}",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This url should not be https:// . It should be configurable so that we can test against local dev box who is simple http://

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's get these in another pull request! They're extremely valid and should be addressed.

:authorize_url => "/puboauth/token",
:token_url => "/puboauth/token"
})
Expand All @@ -39,7 +45,7 @@ def initialize(opts, strategy=:implicit, backoff=0.5)
:password => @password,
:grant_type => 'password'
}
response = RestClient.post "https://#{@domain}.#{EGNYTE_DOMAIN}/puboauth/token", token_request_params
response = RestClient.post "https://#{@domain}/puboauth/token", token_request_params
token = JSON.parse(response)["access_token"]
@access_token = OAuth2::AccessToken.new(@client, token)
else
Expand Down
4 changes: 2 additions & 2 deletions lib/egnyte/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,15 @@ def user_path
end

def self.user_path(session)
"https://#{session.domain}.#{EGNYTE_DOMAIN}/#{session.api}/v2/users"
"https://#{session.domain}/#{session.api}/v2/users"
end

def user_permission_path
Egnyte::User.user_permission_path(@session)
end

def self.user_permission_path(session)
"https://#{session.domain}.#{EGNYTE_DOMAIN}/#{session.api}/v1/perms/user"
"https://#{session.domain}/#{session.api}/v1/perms/user"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. We need a function to generate a url.
  2. /v2/users and /v1/perms/user should be a constant

end

end
Expand Down