Skip to content

Commit

Permalink
🚧 Adding Proxy Support
Browse files Browse the repository at this point in the history
  • Loading branch information
p-samuel committed Sep 23, 2023
1 parent 6c402ea commit 16bad98
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Notify.Api.Indy.pas
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,15 @@ function TNotifyApiIndy.Config(const AValue: INotifyConfig): INotifyApi;
begin
Result := Self;
FNotifyConfig := AValue;

if AValue.ProxyServer <> '' then
begin
FIdHttp.ProxyParams.ProxyServer := AValue.ProxyServer;
FIdHttp.ProxyParams.ProxyUsername := AValue.ProxyUser;
FIdHttp.ProxyParams.ProxyPassword := AValue.ProxyPassword;
FIdHttp.ProxyParams.ProxyPort := AValue.ProxyPort;
end;

end;

constructor TNotifyApiIndy.Create;
Expand Down
5 changes: 5 additions & 0 deletions src/Notify.Config.Contract.pas
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ interface
function LogPath(const AValue: String): INotifyConfig; overload;
function SubscriptionType: TNotifySubscriptionType; overload;
function SubscriptionType(const AValue: TNotifySubscriptionType): INotifyConfig; overload;
function ProxyServer: string; overload;
function ProxyUser: string; overload;
function ProxyPassword: string; overload;
function ProxyPort: integer; overload;
function Proxy(const aProxyServer, aProxyUser, aProxyPassword: string; const aProxyPort: integer): INotifyConfig; overload;
end;

implementation
Expand Down
35 changes: 35 additions & 0 deletions src/Notify.Config.pas
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ TNotifyConfig = class sealed(TInterfacedObject, INotifyConfig)
FSaveLog: Boolean;
FLogPath: String;
FSubscriptionType: TNotifySubscriptionType;
FProxyServer, FProxyUser, FProxyPassword: string;
FProxyPort: integer;
public
class function New: INotifyConfig;
private
Expand All @@ -37,6 +39,11 @@ TNotifyConfig = class sealed(TInterfacedObject, INotifyConfig)
function LogPath(const AValue: String): INotifyConfig; overload;
function SubscriptionType: TNotifySubscriptionType; overload;
function SubscriptionType(const AValue: TNotifySubscriptionType): INotifyConfig; overload;
function ProxyServer: string; overload;
function ProxyUser: string; overload;
function ProxyPassword: string; overload;
function ProxyPort: integer; overload;
function Proxy(const aProxyServer, aProxyUser, aProxyPassword: string; const aProxyPort: integer): INotifyConfig; overload;
end;

implementation
Expand Down Expand Up @@ -114,6 +121,34 @@ function TNotifyConfig.Password(const AValue: String): INotifyConfig;
FPassword := AValue;
end;

function TNotifyConfig.Proxy(const AProxyServer, AProxyUser, AProxyPassword: string; const aProxyPort: integer): INotifyConfig;
begin
FProxyServer := AProxyServer;
FProxyUser := AProxyUser;
FProxyPassword := AProxyPassword;
FProxyPort := AProxyPort;
end;

function TNotifyConfig.ProxyPassword: string;
begin
Result := FProxyPassword;
end;

function TNotifyConfig.ProxyPort: integer;
begin
Result := FProxyPort;
end;

function TNotifyConfig.ProxyServer: string;
begin
Result := FProxyServer;
end;

function TNotifyConfig.ProxyUser: string;
begin
Result := FProxyUser;
end;

function TNotifyConfig.SaveLog(const AValue: Boolean): INotifyConfig;
begin
Result := Self;
Expand Down
1 change: 1 addition & 0 deletions src/Notify.Core.Contract.pas
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ interface
function Since(const AValue: String): INotifyCore; overload;
function Scheduled(const AValue: Boolean): INotifyCore; overload;
function Response: TNotifyApiResponse;
function Proxy(const AProxyServer, AProxyUser, AProxyPassword: String; const AProxyPort: Integer): INotifyCore; overload;
end;

INotifyCoreFacade = interface
Expand Down
7 changes: 7 additions & 0 deletions src/Notify.Core.pas
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ TNotifyCore = class sealed(TInterfacedObject, INotifyCore)
function UserName(const AValue: String): INotifyCore;
function Password(const AValue: String): INotifyCore;
function BaseURL(const AValue: String): INotifyCore;
function Proxy(const aProxyServer, aProxyUser, aProxyPassword: string; const aProxyPort: integer): INotifyCore;
function DisableFireBase(const AValue: Boolean): INotifyCore;
function Notification(const ANotification: INotifyNotification): INotifyCore; overload;
function Filter(const AFilterType: TNotifyFilter; const AValue: String): INotifyCore;
Expand Down Expand Up @@ -344,6 +345,12 @@ function TNotifyCore.Poll(const AValue: Boolean): INotifyCore;
FPoll := AValue;
end;

function TNotifyCore.Proxy(const aProxyServer, aProxyUser,
aProxyPassword: string; const aProxyPort: integer): INotifyCore;
begin
FConfig.Proxy(aProxyServer, aProxyUser, aProxyPassword, aProxyPort);
end;

function TNotifyCore.Publish: INotifyCore;
begin
Result := Self;
Expand Down

0 comments on commit 16bad98

Please sign in to comment.