Changeset 5 for trunk/UFioAPI.pas
- Timestamp:
- Mar 14, 2013, 7:55:02 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UFioAPI.pas
r4 r5 6 6 7 7 uses 8 Classes, SysUtils, httpsend ;8 Classes, SysUtils, httpsend, ssl_openssl; 9 9 10 10 type … … 13 13 14 14 TFioAPI = class 15 private 16 function Download(URL: string; Data: TStrings): Boolean; 17 public 15 18 Token: string; 16 19 Format: string; 17 function Download: Boolean; 20 function DownloadInterval(TimeFrom, TimeTo: TDateTime; Data: TStrings): Boolean; 21 function DownloadMonthly(Year, Id: Integer; Data: TStrings): Boolean; 22 function DownloadLast(Data: TStrings): Boolean; 18 23 end; 19 24 … … 22 27 { TFioAPI } 23 28 24 function TFioAPI.Download : Boolean;29 function TFioAPI.Download(URL: string; Data: TStrings): Boolean; 25 30 var 26 31 HTTPSender: THTTPSend; … … 30 35 Format := 'xml'; 31 36 Token := 'dd'; 32 // HTTPSender.HTTPMethod('GET', 'https://www.fio.cz/ib_api/rest/periods/' + Token + 33 // '/2013-03-01/2013-03-15/transactions.' + Format); 34 HTTPSender.HTTPMethod('GET', 'https://www.fio.cz/e-broker/e-broker.cgi'); 37 HTTPSender.HTTPMethod('GET', URL); 35 38 try 36 39 case HTTPSender.Resultcode of 37 40 100..299: 38 41 begin 39 { with TFileStream.Create(TargetFile, fmCreate or fmOpenWrite) do 40 try 41 Seek(0, soFromBeginning); 42 CopyFrom(HTTPSender.Document, 0); 43 finally 44 Free; 45 end;} 42 Data.LoadFromStream(HTTPSender.Document); 46 43 Result := True; 47 44 end; //informational, success … … 53 50 except 54 51 // We don't care for the reason for this error; the download failed. 55 Result := false;52 Result := False; 56 53 end; 57 54 finally … … 60 57 end; 61 58 59 function TFioAPI.DownloadInterval(TimeFrom, TimeTo: TDateTime; Data: TStrings 60 ): Boolean; 61 begin 62 Result := Download('https://www.fio.cz/ib_api/rest/periods/' + Token + 63 '/' + FormatDateTime('yyyy-mm-dd', TimeFrom) + 64 '/' + FormatDateTime('yyyy-mm-dd', TimeTo) + 65 '/transactions.' + Format, Data); 66 end; 67 68 function TFioAPI.DownloadMonthly(Year, Id: Integer; Data: TStrings): Boolean; 69 begin 70 Result := Download('https://www.fio.cz/ib_api/rest/by-id/' + Token + 71 '/' + IntToStr(Year) + '/' + IntToStr(Id) + 72 '/transactions.' + Format, Data); 73 end; 74 75 function TFioAPI.DownloadLast(Data: TStrings): Boolean; 76 begin 77 Result := Download('https://www.fio.cz/ib_api/rest/last/' + Token + 78 '/transactions.' + Format, Data); 79 end; 80 62 81 end. 63 82
Note:
See TracChangeset
for help on using the changeset viewer.