Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Vlad Bukhanets
/
immoscout24-api-php
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Merge Requests
0
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
fa4d2ad6
authored
2020-01-14 15:23:10 +0100
by
fehrlich
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
added method to create simple attachments
1 parent
af5d08c6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
17 deletions
src/ImmoScoutAPI.php
src/ImmoScoutAPI.php
View file @
fa4d2ad
...
...
@@ -182,7 +182,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
{
$domain
=
$this
->
getDomain
();
return
'https://rest.'
.
$domain
.
'/restapi/'
;
return
'https://rest.'
.
$domain
.
'/restapi/'
;
}
/**
...
...
@@ -266,7 +266,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
throw
new
InvalidResponse
(
'Could not parse the requested request token'
);
}
$this
->
saveRequestToken
(
$body
[
'oauth_token'
],
$body
[
'oauth_token_secret'
]);
header
(
'Location: '
.
$this
->
getBaseUrl
()
.
'security/oauth/confirm_access?oauth_token='
.
$body
[
'oauth_token'
]);
header
(
'Location: '
.
$this
->
getBaseUrl
()
.
'security/oauth/confirm_access?oauth_token='
.
$body
[
'oauth_token'
]);
exit
();
}
...
...
@@ -369,7 +369,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
}
$path
=
str_replace
(
'{user}'
,
$this
->
user
,
$path
);
return
$url
.
$path
;
return
$url
.
$path
;
}
/**
...
...
@@ -518,7 +518,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
$msgs
=
$this
->
parseMessages
(
$res
);
if
(
!
isset
(
$msgs
[
'parsed'
][
$expectedResponse
]))
{
$code
=
isset
(
$msgs
[
'parsed'
][
'ERROR_RESOURCE_NOT_FOUND'
])
?
404
:
null
;
throw
new
InvalidResponse
(
'Did not get expected response: '
.
$res
->
getBody
(),
$code
,
null
,
$res
,
$msgs
);
throw
new
InvalidResponse
(
'Did not get expected response: '
.
$res
->
getBody
(),
$code
,
null
,
$res
,
$msgs
);
}
if
(
$expectedResponse
==
'MESSAGE_RESOURCE_CREATED'
)
{
return
$msgs
[
'parsed'
][
$expectedResponse
][
0
];
...
...
@@ -585,7 +585,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
*/
public
function
updateRealEstate
(
$id
,
$obj
)
{
$res
=
$this
->
callUserMethod
(
'realestate/'
.
$id
.
'?usenewenergysourceenev2014values=true'
,
'PUT'
,
$obj
);
$res
=
$this
->
callUserMethod
(
'realestate/'
.
$id
.
'?usenewenergysourceenev2014values=true'
,
'PUT'
,
$obj
);
return
$this
->
checkForResponseUpdated
(
$res
);
}
...
...
@@ -600,7 +600,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
*/
public
function
deleteAttachment
(
$reId
,
$attachmentId
)
{
$res
=
$this
->
callUserMethod
(
'realestate/'
.
$reId
.
'/attachment/'
.
$attachmentId
,
'DELETE'
);
$res
=
$this
->
callUserMethod
(
'realestate/'
.
$reId
.
'/attachment/'
.
$attachmentId
,
'DELETE'
);
return
$this
->
checkForResponseDeleted
(
$res
);
}
...
...
@@ -625,7 +625,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
*/
public
function
createAttachment
(
$objId
,
$attachmentData
,
$content
,
$mimeType
=
'image/jpeg'
,
$fileName
=
'image.jpg'
)
{
$res
=
$this
->
callUserMethod
(
'realestate/'
.
$objId
.
'/attachment/'
,
'POST'
,
[
$res
=
$this
->
callUserMethod
(
'realestate/'
.
$objId
.
'/attachment/'
,
'POST'
,
[
'multipart'
=>
[
[
'Content-type'
=>
'application/json'
,
...
...
@@ -645,6 +645,21 @@ abstract class ImmoScoutAPI extends GuzzleClient
}
/**
* create simple attachment for an realestate, without a file attached.
*
* @param string $objId realestate id used by is24
* @param array $attachmentData compatible with https://api.immobilienscout24.de/our-apis/import-export/attachments/post.html
*
* @return string returns the id that is used by is24, this should be saved
*/
public
function
createSimpleAttachment
(
$objId
,
$attachmentData
)
{
$res
=
$this
->
callUserMethod
(
'realestate/'
.
$objId
.
'/attachment/'
,
'POST'
,
$attachmentData
);
return
$this
->
checkForResponseCreated
(
$res
);
}
/**
* update realestate attachment.
*
* @param string $objId realestate id used by is24
...
...
@@ -655,7 +670,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
*/
public
function
updateAttachment
(
$objId
,
$id
,
$attachmentData
)
{
$res
=
$this
->
callUserMethod
(
'realestate/'
.
$objId
.
'/attachment/'
.
$id
,
'PUT'
,
$attachmentData
);
$res
=
$this
->
callUserMethod
(
'realestate/'
.
$objId
.
'/attachment/'
.
$id
,
'PUT'
,
$attachmentData
);
return
$this
->
checkForResponseUpdated
(
$res
);
}
...
...
@@ -670,7 +685,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
*/
public
function
updateAttachmentOrder
(
$objId
,
$orderArray
)
{
$res
=
$this
->
callUserMethod
(
'realestate/'
.
$objId
.
'/attachment/attachmentsorder'
,
'PUT'
,
[
$res
=
$this
->
callUserMethod
(
'realestate/'
.
$objId
.
'/attachment/attachmentsorder'
,
'PUT'
,
[
'attachmentsorder.attachmentsorder'
=>
[
'@xmlns'
=>
[
'attachmentsorder'
=>
'http://rest.immobilienscout24.de/schema/attachmentsorder/1.0'
,
...
...
@@ -701,19 +716,21 @@ abstract class ImmoScoutAPI extends GuzzleClient
/**
* Get an array of all contacts that can be specified for a real estate.
* @param string $reId realestate id used by is24 *
*
* @param string $reId realestate id used by is24 *
*/
public
function
delete
(
$reId
)
{
$res
=
$this
->
callUserMethod
(
'realestate/'
.
$reId
,
'DELETE'
);
$res
=
$this
->
callUserMethod
(
'realestate/'
.
$reId
,
'DELETE'
);
return
$this
->
checkForResponseDeleted
(
$res
);
}
/**
* Get an array of all contacts that can be specified for a real estate.
* @param string $reId realestate id used by is24
* @param string $publishchannel publish channel id like 10000
*
* @param string $reId realestate id used by is24
* @param string $publishchannel publish channel id like 10000
*/
public
function
publish
(
$reId
,
$publishchannel
=
'10000'
)
{
...
...
@@ -732,13 +749,14 @@ abstract class ImmoScoutAPI extends GuzzleClient
}
/**
* unpublish a real estate
* @param string $reId realestate id used by is24
* @param string $publishchannel publish channel id like 10000
* unpublish a real estate.
*
* @param string $reId realestate id used by is24
* @param string $publishchannel publish channel id like 10000
*/
public
function
unpublish
(
$reId
,
$publishchannel
=
'10000'
)
{
$res
=
$this
->
callMethod
(
'publish/'
.
$reId
.
'_'
.
$publishchannel
,
'DELETE'
);
$res
=
$this
->
callMethod
(
'publish/'
.
$reId
.
'_'
.
$publishchannel
,
'DELETE'
);
return
$this
->
checkForResponseDeleted
(
$res
);
}
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment