Skip to content

Commit

Permalink
fix: update adorable api to api.hello-avatar.com (#4778)
Browse files Browse the repository at this point in the history
  • Loading branch information
wipash authored Jan 13, 2021
1 parent 4d61995 commit 527131e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/Services/Contact/Avatar/GetAdorableAvatarURL.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class GetAdorableAvatarURL extends BaseService
{
private const ADORABLE_API = 'https://api.adorable.io/avatars/';
private const ADORABLE_API = 'https://api.hello-avatar.com/adorables/';

/**
* Get the validation rules that apply to the service.
Expand Down
24 changes: 24 additions & 0 deletions database/migrations/2021_01_10_235600_update_adorable_api.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

use App\Models\Contact\Contact;
use Illuminate\Database\Migrations\Migration;

class UpdateAdorableAPI extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Contact::without(['account', 'avatarPhoto', 'gender'])
->where('avatar_adorable_url', 'like', '%api.adorable.io%')
->chunk(1000, function ($contacts) {
foreach ($contacts as $contact) {
$contact->avatar_adorable_url = str_replace('api.adorable.io/avatars', 'api.hello-avatar.com/adorables', $contact->avatar_adorable_url);
$contact->save();
}
});
}
}
4 changes: 2 additions & 2 deletions tests/Unit/Services/Contact/Avatar/GetAdorableAvatarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function it_returns_an_url()
$url = app(GetAdorableAvatarURL::class)->execute($request);

$this->assertEquals(
'https://api.adorable.io/avatars/400/matt@wordpress.com.png',
'https://api.hello-avatar.com/adorables/400/matt@wordpress.com.png',
$url
);
}
Expand All @@ -38,7 +38,7 @@ public function it_returns_an_url_with_a_default_avatar_size()

// should return an avatar of 200 px wide
$this->assertEquals(
'https://api.adorable.io/avatars/200/matt@wordpress.com.png',
'https://api.hello-avatar.com/adorables/200/matt@wordpress.com.png',
$url
);
}
Expand Down

0 comments on commit 527131e

Please sign in to comment.